about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-04-12 19:33:34 +0100
committerGitHub <noreply@github.com>2024-04-12 11:33:34 -0700
commit835f2e6548a9a55fded1f506b17692154a07caab (patch)
tree9988400824e6e7ae509ce023d0a56b9994a5ac8c /src/lib
parent14208eef11b1598af7b9bfc855e608c231850d4d (diff)
downloadvoidsky-835f2e6548a9a55fded1f506b17692154a07caab.tar.zst
Fix stale Notifications after push (#3507)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/notifications/notifications.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts
index 0f628f428..e0b3d8f3d 100644
--- a/src/lib/notifications/notifications.ts
+++ b/src/lib/notifications/notifications.ts
@@ -4,6 +4,7 @@ import {QueryClient} from '@tanstack/react-query'
 
 import {logger} from '#/logger'
 import {RQKEY as RQKEY_NOTIFS} from '#/state/queries/notifications/feed'
+import {invalidateCachedUnreadPage} from '#/state/queries/notifications/unread'
 import {truncateAndInvalidate} from '#/state/queries/util'
 import {getAgent, SessionAccount} from '#/state/session'
 import {track} from 'lib/analytics/analytics'
@@ -87,6 +88,7 @@ export function useNotificationsListener(queryClient: QueryClient) {
     // handle notifications that are received, both in the foreground or background
     // NOTE: currently just here for debug logging
     const sub1 = Notifications.addNotificationReceivedListener(event => {
+      invalidateCachedUnreadPage()
       logger.debug(
         'Notifications: received',
         {event},
@@ -131,11 +133,13 @@ export function useNotificationsListener(queryClient: QueryClient) {
           )
           track('Notificatons:OpenApp')
           logEvent('notifications:openApp', {})
+          invalidateCachedUnreadPage()
           truncateAndInvalidate(queryClient, RQKEY_NOTIFS())
           resetToTab('NotificationsTab') // open notifications tab
         }
       },
     )
+
     return () => {
       sub1.remove()
       sub2.remove()