about summary refs log tree commit diff
path: root/src/state/queries/notifications/unread.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-01-30 17:46:35 -0800
committerGitHub <noreply@github.com>2024-01-30 17:46:35 -0800
commit45291f17a08acb8b62d0ff86f2ce40ad4fa9f1f6 (patch)
treeddd4a3e093fe4bb5e1bb3e9596f95693588a3f76 /src/state/queries/notifications/unread.tsx
parenta175922ccf806b529ee9c18b62d602f6c91d0f54 (diff)
downloadvoidsky-45291f17a08acb8b62d0ff86f2ce40ad4fa9f1f6.tar.zst
Fix notification mark-read behaviors (#2696)
* Mark read on first notifs page fetch always; this is less optimal but it fixes a case where when the first full page's unreads are all filtered out

* Use the pre-filter indexedAt for updateSeen
Diffstat (limited to 'src/state/queries/notifications/unread.tsx')
-rw-r--r--src/state/queries/notifications/unread.tsx10
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,
           }