From 98836eefac62d733e3f5f5a81624ee20ce9a0bb2 Mon Sep 17 00:00:00 2001 From: gsovereignty Date: Mon, 12 Aug 2024 21:29:18 +0800 Subject: [PATCH] problem: can't see pending bitcoin address additions --- src/components/AssociateBitcoinAddress.svelte | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/AssociateBitcoinAddress.svelte b/src/components/AssociateBitcoinAddress.svelte index 87f9a72..0850d4c 100644 --- a/src/components/AssociateBitcoinAddress.svelte +++ b/src/components/AssociateBitcoinAddress.svelte @@ -10,10 +10,29 @@ import validate from 'bitcoin-address-validation'; import type { Rocket } from '@/event_helpers/rockets'; import { derived } from 'svelte/store'; + import { onDestroy } from 'svelte'; + import type { NDKEventStore, ExtendedBaseType } from '@nostr-dev-kit/ndk-svelte'; let bitcoinAddress: string; export let rocket: Rocket; + let associations: NDKEventStore> | undefined = undefined; + + $: { + if ($currentUser && !associations) { + associations = $ndk.storeSubscribe( + [{ authors: [$currentUser.pubkey], kinds: [1413 as number] }], + { + subId: `1413-${$currentUser.pubkey}` + } + ); + } + } + + onDestroy(() => { + associations?.unsubscribe(); + }); + let associatedAddresses = derived(currentUser, ($currentUser) => { let addresses: Set = new Set(); if ($currentUser) { @@ -64,13 +83,23 @@ their Merits. Merit purchases must be conducted with a Bitcoin address that is associated with your pubkey, otherwise you will not recieve the Merits upon payment. - {#if $associatedAddresses.size == 0}You do not have any registered addresses{:else} - Your registered addresses: + {#if ($associatedAddresses.size == 0 && !associations) || (associations && $associations.length == 0)}You + do not have any registered addresses{:else if associations && $associations && $associations.length > 0} +

Pending Additions

+
    + {#each $associations as event}
  • + {event.getMatchingTags('onchain')[0][1]} +
  • {/each} +
+ {:else} +

Your registered addresses

+
    {#each $associatedAddresses as address}
  • {address}
  • {/each}
{/if} - Add a new address now +

Add a new address now

+