Handle contacts with no npub/lnurl

This commit is contained in:
benthecarman
2024-03-27 16:54:50 -05:00
committed by Paul Miller
parent 155777e825
commit 0afd2e75e0
2 changed files with 36 additions and 4 deletions

View File

@@ -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}`);

View File

@@ -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);
}