From fa2eb42bf93bc2367ecd2ba37232bbea3ada349b Mon Sep 17 00:00:00 2001 From: Jure <44338+hoornet@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:31:37 +0200 Subject: [PATCH] Fix repeated follower OS notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kind 3 events are replaceable — same person produces a new event ID every time they update their contact list. Dedup followers by pubkey instead of event ID to prevent re-notifying. --- src/lib/notificationPoller.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/notificationPoller.ts b/src/lib/notificationPoller.ts index 8eb1790..884383e 100644 --- a/src/lib/notificationPoller.ts +++ b/src/lib/notificationPoller.ts @@ -76,11 +76,17 @@ async function pollOnce(pubkey: string) { } } catch { /* non-critical */ } - // New followers + // New followers — dedup by pubkey, not event ID (kind 3 is replaceable, same + // person produces a new event ID every time they update their contact list) try { const followersSince = (await dbNewestNotificationTs(pubkey, "follower")) ?? (now - 300); const followers = await fetchNewFollowers(pubkey, followersSince, 5); - const newFollowers = followers.filter((e) => e.pubkey !== pubkey && !existingIds.has(e.id!)); + const existingFollowerPubkeys = new Set( + useNotificationsStore.getState().notifications + .filter((e) => e.kind === 3) + .map((e) => e.pubkey) + ); + const newFollowers = followers.filter((e) => e.pubkey !== pubkey && !existingFollowerPubkeys.has(e.pubkey)); if (newFollowers.length > 0) { dbSaveNotifications(newFollowers.map((e) => JSON.stringify(e.rawEvent())), pubkey, "follower"); for (const e of newFollowers) {