From bd1a4b198e3682f96354d83f1e1efccf31813f82 Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Wed, 16 Nov 2022 14:36:16 -0600
Subject: [PATCH] Clear notifications count optimistically

---
 src/state/models/me.ts                 | 4 ++++
 src/state/models/notifications-view.ts | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/state/models/me.ts b/src/state/models/me.ts
index cefd893c..78c6d2e7 100644
--- a/src/state/models/me.ts
+++ b/src/state/models/me.ts
@@ -49,6 +49,10 @@ export class MeModel {
     }
   }
 
+  clearNotificationCount() {
+    this.notificationCount = 0
+  }
+
   async fetchStateUpdate() {
     const res = await this.rootStore.api.app.bsky.notification.getCount()
     runInAction(() => {
diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts
index c328be62..b841c7f3 100644
--- a/src/state/models/notifications-view.ts
+++ b/src/state/models/notifications-view.ts
@@ -332,6 +332,7 @@ export class NotificationsViewModel {
       await this.rootStore.api.app.bsky.notification.updateSeen({
         seenAt: new Date().toISOString(),
       })
+      this.rootStore.me.clearNotificationCount()
     } catch (e) {
       console.log('Failed to update notifications read state', e)
     }