about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-08-22 16:36:49 -0700
committerGitHub <noreply@github.com>2023-08-22 16:36:49 -0700
commit54706a04379127694be24461fdfb5f76c576fce0 (patch)
tree9477a27880bc1e87d584650cb5a5820a4fb087b6 /src
parentfcea27ea0b718ae3ac87d7efd0970e01ab175aca (diff)
downloadvoidsky-54706a04379127694be24461fdfb5f76c576fce0.tar.zst
Fix: update posts rendered in notifs on refresh (close #1196) (#1243)
Diffstat (limited to 'src')
-rw-r--r--src/state/models/feeds/notifications.ts20
-rw-r--r--src/view/com/post/Post.tsx7
2 files changed, 21 insertions, 6 deletions
diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts
index 50a411379..f52853070 100644
--- a/src/state/models/feeds/notifications.ts
+++ b/src/state/models/feeds/notifications.ts
@@ -225,10 +225,22 @@ export class NotificationsFeedItemModel {
   }
 
   setAdditionalData(additionalPost: AppBskyFeedDefs.PostView) {
-    this.additionalPost = PostThreadModel.fromPostView(
-      this.rootStore,
-      additionalPost,
-    )
+    if (this.additionalPost) {
+      this.additionalPost._replaceAll({
+        success: true,
+        headers: {},
+        data: {
+          thread: {
+            post: additionalPost,
+          },
+        },
+      })
+    } else {
+      this.additionalPost = PostThreadModel.fromPostView(
+        this.rootStore,
+        additionalPost,
+      )
+    }
   }
 }
 
diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx
index 673ddefcf..86cb24f9b 100644
--- a/src/view/com/post/Post.tsx
+++ b/src/view/com/post/Post.tsx
@@ -51,12 +51,15 @@ export const Post = observer(function Post({
 
   useEffect(() => {
     if (initView || view?.params.uri === uri) {
-      return // no change needed? or trigger refresh?
+      if (initView !== view) {
+        setView(initView)
+      }
+      return
     }
     const newView = new PostThreadModel(store, {uri, depth: 0})
     setView(newView)
     newView.setup().catch(err => store.log.error('Failed to fetch post', err))
-  }, [initView, uri, view?.params.uri, store])
+  }, [initView, setView, uri, view, view?.params.uri, store])
 
   // deleted
   // =