mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-02 21:14:27 +01:00
Handle contacts with no npub/lnurl
This commit is contained in:
committed by
Paul Miller
parent
155777e825
commit
0afd2e75e0
@@ -15,8 +15,16 @@ export function SocialActionRow(props: {
|
||||
|
||||
const getContacts = cache(async () => {
|
||||
try {
|
||||
const contacts = await state.mutiny_wallet?.get_contacts_sorted();
|
||||
return contacts || [];
|
||||
const contacts: TagItem[] =
|
||||
(await state.mutiny_wallet?.get_contacts_sorted()) || [];
|
||||
|
||||
// contact must have a npub, ln_address, or lnurl
|
||||
return contacts.filter(
|
||||
(contact) =>
|
||||
contact.npub !== undefined ||
|
||||
contact.ln_address !== undefined ||
|
||||
contact.lnurl !== undefined
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return [];
|
||||
@@ -69,7 +77,7 @@ export function SocialActionRow(props: {
|
||||
name={contact.name}
|
||||
image_url={contact.primal_image_url}
|
||||
onClick={() => {
|
||||
if (profileDeleted()) {
|
||||
if (profileDeleted() || !contact.npub) {
|
||||
sendToContact(contact);
|
||||
} else {
|
||||
navigate(`/chat/${contact.id}`);
|
||||
|
||||
@@ -246,7 +246,31 @@ function ActualSearch(props: { initialValue?: string }) {
|
||||
throw new Error("no contact returned");
|
||||
}
|
||||
|
||||
sendToContact(tagItem);
|
||||
// if the new contact has an npub, send to chat
|
||||
// otherwise, send to send page
|
||||
if (tagItem.npub) {
|
||||
sendToContact(tagItem);
|
||||
} else if (tagItem.ln_address) {
|
||||
actions.handleIncomingString(
|
||||
tagItem.ln_address,
|
||||
() => {},
|
||||
() => {
|
||||
navigate("/send");
|
||||
}
|
||||
);
|
||||
} else if (tagItem.lnurl) {
|
||||
actions.handleIncomingString(
|
||||
tagItem.lnurl,
|
||||
() => {},
|
||||
() => {
|
||||
navigate("/send");
|
||||
}
|
||||
);
|
||||
} else {
|
||||
console.error(
|
||||
"No npub, ln_address, or lnurl found, this should never happen"
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user