Skip to content

Commit

Permalink
add indicator if user has zapped event
Browse files Browse the repository at this point in the history
  • Loading branch information
chakany committed Dec 7, 2024
1 parent db262aa commit 1f09152
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Recipe/TotalZaps.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
let loading = true;
let totalZapAmount: number = 0;
let didSigs = new Map();
let hasUserZapped = false;
async function fetch() {
const sub = await $ndk.subscribe({
Expand All @@ -24,9 +25,12 @@
totalZapAmount =
totalZapAmount + Number(decoded.sections.find((e) => e.name == 'amount').value);
didSigs.set(event.sig, event.sig);
if (event.tags.some(tag => tag[0] === 'P' && tag[1] === $userPublickey)) {
hasUserZapped = true;
}
}
}
});
}
Expand All @@ -37,6 +41,6 @@
</script>

<div class="flex gap-1.5 hover:bg-input rounded px-0.5 transition duration-300">
<LightningIcon size={24} />
<LightningIcon size={24} color={hasUserZapped ? '#facc15' : ''} weight={hasUserZapped ? "fill" : "regular"} />
{#if loading}...{:else}{formatAmount(totalZapAmount / 1000)} sats{/if}
</div>

0 comments on commit 1f09152

Please sign in to comment.