Skip to content

Commit

Permalink
Handle contacts with no npub/lnurl
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and futurepaul committed Apr 5, 2024
1 parent 155777e commit 0afd2e7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/components/SocialActionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down Expand Up @@ -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}`);
Expand Down
26 changes: 25 additions & 1 deletion src/routes/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0afd2e7

Please sign in to comment.