mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-18 06:44:27 +01:00
add limit for get_contacts_sorted
This commit is contained in:
committed by
Tony Giorgio
parent
60f1ab888b
commit
57af14fb9b
@@ -1,4 +1,3 @@
|
|||||||
import { TagItem } from "@mutinywallet/mutiny-wasm";
|
|
||||||
import { useNavigate } from "@solidjs/router";
|
import { useNavigate } from "@solidjs/router";
|
||||||
import { Check, PlugZap, X } from "lucide-solid";
|
import { Check, PlugZap, X } from "lucide-solid";
|
||||||
import {
|
import {
|
||||||
@@ -42,7 +41,7 @@ export function PendingNwc() {
|
|||||||
setHasPreConfiguredNWC(!!profiles && profiles.length > 0);
|
setHasPreConfiguredNWC(!!profiles && profiles.length > 0);
|
||||||
if (!profiles) return [];
|
if (!profiles) return [];
|
||||||
|
|
||||||
const contacts: TagItem[] | undefined = await sw.get_contacts_sorted();
|
const contacts = await sw.get_contacts_sorted();
|
||||||
if (!contacts) return [];
|
if (!contacts) return [];
|
||||||
|
|
||||||
const pending = await sw.get_pending_nwc_invoices();
|
const pending = await sw.get_pending_nwc_invoices();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function SocialActionRow(props: {
|
|||||||
|
|
||||||
const getContacts = cache(async () => {
|
const getContacts = cache(async () => {
|
||||||
try {
|
try {
|
||||||
const contacts: TagItem[] = (await sw.get_contacts_sorted()) || [];
|
const contacts = await sw.get_contacts_sorted(40);
|
||||||
const myNpub = (await sw.get_npub()) || "";
|
const myNpub = (await sw.get_npub()) || "";
|
||||||
|
|
||||||
// contact must have a npub, ln_address, or lnurl
|
// contact must have a npub, ln_address, or lnurl
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ function ActualSearch(props: { initialValue?: string }) {
|
|||||||
|
|
||||||
const getContacts = cache(async () => {
|
const getContacts = cache(async () => {
|
||||||
try {
|
try {
|
||||||
const contacts = await sw.get_contacts_sorted();
|
return await sw.get_contacts_sorted(40);
|
||||||
return contacts || ([] as TagItem[]);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
return [] as TagItem[];
|
return [] as TagItem[];
|
||||||
|
|||||||
@@ -384,9 +384,14 @@ export async function get_invoice(
|
|||||||
* Gets all contacts sorted by last used
|
* Gets all contacts sorted by last used
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function get_contacts_sorted(): Promise<TagItem[] | undefined> {
|
export async function get_contacts_sorted(limit?: number): Promise<TagItem[]> {
|
||||||
const contacts = await wallet!.get_contacts_sorted();
|
const contacts = await wallet!.get_contacts_sorted();
|
||||||
return contacts;
|
if (!contacts) return [];
|
||||||
|
if (contacts.length && limit) {
|
||||||
|
return contacts.slice(0, limit);
|
||||||
|
} else {
|
||||||
|
return contacts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function edit_contact(
|
export async function edit_contact(
|
||||||
@@ -966,7 +971,6 @@ export async function approve_nostr_wallet_auth(
|
|||||||
*/
|
*/
|
||||||
export async function get_nwc_profile(index: number): Promise<NwcProfile> {
|
export async function get_nwc_profile(index: number): Promise<NwcProfile> {
|
||||||
const profile = await wallet!.get_nwc_profile(index);
|
const profile = await wallet!.get_nwc_profile(index);
|
||||||
console.log("get_nwc_profile", profile);
|
|
||||||
return {
|
return {
|
||||||
...profile.value
|
...profile.value
|
||||||
} as NwcProfile;
|
} as NwcProfile;
|
||||||
|
|||||||
Reference in New Issue
Block a user