Skip to content

Commit

Permalink
Special case Zapple Pay zaps
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Apr 18, 2024
1 parent 8608c4d commit 713c1a6
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/components/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import {

import { GenericItem } from "./GenericItem";

const ZAPPLE_PAY_NPUB =
"npub1wxl6njlcgygduct7jkgzrvyvd9fylj4pqvll6p32h59wyetm5fxqjchcan";

export type HackActivityType =
| "Lightning"
| "OnChain"
Expand Down Expand Up @@ -85,7 +88,12 @@ export function UnifiedActivityItem(props: {
if (props.item.contacts.length === 0) {
return undefined;
}
return props.item.contacts[0];
// if it's a zapple pay, don't show the contact, parse the label
const contact = props.item.contacts[0];
if (contact.npub && contact.npub === ZAPPLE_PAY_NPUB) {
return undefined;
}
return contact;
});

const getContact = cache(async (npub) => {
Expand All @@ -108,6 +116,25 @@ export function UnifiedActivityItem(props: {
}
}
}
} else if (
// if zapple pay, handle it specially
props.item.contacts[0].npub === ZAPPLE_PAY_NPUB
) {
if (props.item.labels) {
const label = props.item.labels.find((l) =>
l.startsWith("From: nostr:npub")
);
if (label) {
// get the npub from the label
const npub = label.split("From: nostr:")[1];
await new Promise((r) => setTimeout(r, 1000));
try {
return await getContact(npub.trim());
} catch (e) {
console.error(e);
}
}
}
}
return undefined;
});
Expand All @@ -118,7 +145,8 @@ export function UnifiedActivityItem(props: {
(l) =>
l !== "SWAP" &&
!l.startsWith("LN Channel:") &&
!l.startsWith("npub")
!l.startsWith("npub") &&
!l.startsWith("From: nostr:npub")
);
if (filtered.length === 0) {
return undefined;
Expand Down

0 comments on commit 713c1a6

Please sign in to comment.