From d138f78837ad9a1856e757ccd0f8155c696c8437 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 25 Jun 2025 22:02:27 +0800 Subject: [PATCH] fix: try to correct notification indicator display issue --- src/providers/NostrProvider/index.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/providers/NostrProvider/index.tsx b/src/providers/NostrProvider/index.tsx index 465cf3f..2674b5c 100644 --- a/src/providers/NostrProvider/index.tsx +++ b/src/providers/NostrProvider/index.tsx @@ -151,9 +151,6 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { } const storedNotificationsSeenAt = storage.getLastReadNotificationTime(account.pubkey) - if (storedNotificationsSeenAt) { - setNotificationsSeenAt(storedNotificationsSeenAt) - } const [ storedRelayListEvent, @@ -258,13 +255,12 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { await indexedDb.putReplaceableEvent(favoriteRelaysEvent) } - if ( - notificationsSeenAtEvent && - notificationsSeenAtEvent.created_at > storedNotificationsSeenAt - ) { - setNotificationsSeenAt(notificationsSeenAtEvent.created_at) - storage.setLastReadNotificationTime(account.pubkey, notificationsSeenAtEvent.created_at) - } + const notificationsSeenAt = Math.max( + notificationsSeenAtEvent?.created_at ?? 0, + storedNotificationsSeenAt + ) + setNotificationsSeenAt(notificationsSeenAt) + storage.setLastReadNotificationTime(account.pubkey, notificationsSeenAt) client.initUserIndexFromFollowings(account.pubkey, controller.signal) return controller