From cceae7fed3faf2d2bbf95d263950d936e098caea Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Sun, 1 Mar 2026 02:35:58 -0600 Subject: [PATCH] Fix duplicate notifications REQ caused by cursor in query key --- src/hooks/useHasUnreadNotifications.ts | 2 +- src/hooks/useNotifications.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/useHasUnreadNotifications.ts b/src/hooks/useHasUnreadNotifications.ts index 9ab93c2b..22864104 100644 --- a/src/hooks/useHasUnreadNotifications.ts +++ b/src/hooks/useHasUnreadNotifications.ts @@ -24,7 +24,7 @@ export function useHasUnreadNotifications(): boolean { : null; const { data: hasUnread = false } = useQuery({ - queryKey: ['notifications-unread', user?.pubkey ?? '', notificationsCursor], + queryKey: ['notifications-unread', user?.pubkey ?? ''], queryFn: async ({ signal }) => { if (!user || notificationsCursor === null) return false; diff --git a/src/hooks/useNotifications.ts b/src/hooks/useNotifications.ts index 56fe279d..371711c0 100644 --- a/src/hooks/useNotifications.ts +++ b/src/hooks/useNotifications.ts @@ -215,6 +215,7 @@ export function useNotifications(): NotificationData { await updateSettings.mutateAsync({ notificationsCursor: newestTimestamp, }); + queryClient.invalidateQueries({ queryKey: ['notifications-unread', user.pubkey] }); } catch (error) { console.error('Failed to mark notifications as read:', error); // Roll back optimistic cursor on failure