From 577a83e2d14346074f57aa25f5dfa35a1ff14a55 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 15 May 2026 13:46:40 -0500 Subject: [PATCH] Hide previously deleted versions on reload The versions modal now fetches the user's NIP-09 kind-5 delete events (scoped to #k=5128) in parallel with the snapshot query and filters out any snapshot ids that appear in an `e` tag. Otherwise a deleted version would reappear the next time the modal was opened because relays still hold the original 5128 event. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/deploy/NsiteVersionsDialog.tsx | 51 +++++++++++++++---- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/components/deploy/NsiteVersionsDialog.tsx b/src/components/deploy/NsiteVersionsDialog.tsx index 7b58a6c0..6ceca5a5 100644 --- a/src/components/deploy/NsiteVersionsDialog.tsx +++ b/src/components/deploy/NsiteVersionsDialog.tsx @@ -97,19 +97,48 @@ export function NsiteVersionsDialog({ setError(null); try { const relayClient = nostr.group(relayUrls); - const events = await relayClient.query( - [{ - kinds: [NSITE_SNAPSHOT_KIND], - authors: [pubkey], - '#a': [parentRef], - limit: QUERY_LIMIT, - }], - { signal: AbortSignal.timeout(QUERY_TIMEOUT_MS) }, - ); + const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS); - // Dedup by event id (relays may return duplicates) and sort newest-first. + // Fetch snapshots and the user's NIP-09 delete events in parallel. + // The delete query is scoped to kind 5128 (the snapshot kind) so it + // returns only deletions relevant to nsite versions. + const [snapshotEvents, deleteEvents] = await Promise.all([ + relayClient.query( + [{ + kinds: [NSITE_SNAPSHOT_KIND], + authors: [pubkey], + '#a': [parentRef], + limit: QUERY_LIMIT, + }], + { signal }, + ), + relayClient.query( + [{ + kinds: [5], + authors: [pubkey], + '#k': [String(NSITE_SNAPSHOT_KIND)], + limit: QUERY_LIMIT, + }], + { signal }, + ).catch(() => []), + ]); + + // Collect every event id targeted by a delete event authored by this + // user (NIP-09 requires author match, which the filter already enforces). + const deletedIds = new Set(); + for (const ev of deleteEvents) { + for (const tag of ev.tags) { + if (tag[0] === 'e' && tag[1]) deletedIds.add(tag[1]); + } + } + + // Dedup by event id (relays may return duplicates), filter out tombstones, + // and sort newest-first. const byId = new Map(); - for (const ev of events) byId.set(ev.id, ev); + for (const ev of snapshotEvents) { + if (deletedIds.has(ev.id)) continue; + byId.set(ev.id, ev); + } const rows: VersionRow[] = Array.from(byId.values()) .sort((a, b) => b.created_at - a.created_at)