about summary refs log tree commit diff
path: root/src/state/queries/notifications/util.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-12-13 12:16:55 -0800
committerGitHub <noreply@github.com>2023-12-13 12:16:55 -0800
commite3ba014be00f545b3dbd39b5dcfc198a69c790d4 (patch)
tree323937c93516efe82dc6f30b748a3d5c4a8333ea /src/state/queries/notifications/util.ts
parenteecf04489f0c580a259a7977271bb35abcf4dbee (diff)
downloadvoidsky-e3ba014be00f545b3dbd39b5dcfc198a69c790d4.tar.zst
More notifications improvements (#2198)
* On mobile, never replace the notifs under the user due to focus events

* Use the server's seenAt response to calculate isRead state locally
Diffstat (limited to 'src/state/queries/notifications/util.ts')
-rw-r--r--src/state/queries/notifications/util.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts
index 9fb25867a..cc5943163 100644
--- a/src/state/queries/notifications/util.ts
+++ b/src/state/queries/notifications/util.ts
@@ -68,8 +68,14 @@ export async function fetchPage({
     notif => !isThreadMuted(notif, threadMutes),
   )
 
+  let seenAt = res.data.seenAt ? new Date(res.data.seenAt) : new Date()
+  if (Number.isNaN(seenAt.getTime())) {
+    seenAt = new Date()
+  }
+
   return {
     cursor: res.data.cursor,
+    seenAt,
     items: notifsGrouped,
   }
 }