diff options
Diffstat (limited to 'src/state/queries/notifications/unread.tsx')
-rw-r--r-- | src/state/queries/notifications/unread.tsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/state/queries/notifications/unread.tsx b/src/state/queries/notifications/unread.tsx index a96b56225..e7a0631ec 100644 --- a/src/state/queries/notifications/unread.tsx +++ b/src/state/queries/notifications/unread.tsx @@ -127,7 +127,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { } // count - const page = await fetchPage({ + const {page, indexedAt: lastIndexed} = await fetchPage({ cursor: undefined, limit: 40, queryClient, @@ -151,12 +151,14 @@ export function Provider({children}: React.PropsWithChildren<{}>) { // track last sync const now = new Date() - const lastIndexed = - page.items[0] && new Date(page.items[0].notification.indexedAt) + const lastIndexedDate = lastIndexed + ? new Date(lastIndexed) + : undefined cacheRef.current = { usableInFeed: !!invalidate, // will be used immediately data: page, - syncedAt: !lastIndexed || now > lastIndexed ? now : lastIndexed, + syncedAt: + !lastIndexedDate || now > lastIndexedDate ? now : lastIndexedDate, unreadCount, } |