Skip to content

Commit d43fecf

Browse files
committed
skip deleted events by default
1 parent 18daf2b commit d43fecf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ndk-svelte/src/index.svelte.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,21 @@ class NDKSvelte extends NDK {
6464
if (existingEvent.created_at! >= e.created_at!) return;
6565
}
6666

67+
// Check if the event is marked as deleted
68+
const isDeleted = e.isParamReplaceable() && e.hasTag("deleted");
69+
70+
// Update the event map
6771
eventMap.set(dedupKey, e as T);
6872

73+
// If the event is deleted and skipDeleted is true (default), remove it from the list
74+
if (isDeleted && opts?.skipDeleted !== false) {
75+
const index = eventList.findIndex(event => event.deduplicationKey() === dedupKey);
76+
if (index !== -1) {
77+
eventList.splice(index, 1);
78+
}
79+
return;
80+
}
81+
6982
// Update the reactive event list inserting the event in the right position according to the created_at timestamp
7083
const pos = eventList.findIndex(event => event.created_at! < e.created_at!);
7184
eventList.splice(pos, 0, e as T);

0 commit comments

Comments
 (0)