Fix stale Notifications after push (#3507)

This commit is contained in:
dan 2024-04-12 19:33:34 +01:00 committed by GitHub
parent 14208eef11
commit 835f2e6548
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 7 deletions

View file

@ -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()