about summary refs log tree commit diff
path: root/src/state/queries/usePostThread/utils.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2025-07-17 13:22:09 -0500
committerGitHub <noreply@github.com>2025-07-17 13:22:09 -0500
commit00b017804bcb811b5f9292a88619423df3a29ef8 (patch)
tree835c1d2d66c9d8473f3e48b49b43e071876575c8 /src/state/queries/usePostThread/utils.ts
parentd13a2e5f69fac4a4a5a89692362b827b8f0223e4 (diff)
downloadvoidsky-00b017804bcb811b5f9292a88619423df3a29ef8.tar.zst
Fix bug where replying to grandparents re-orders thread (#8662)
* Fix bug where optimistic replies were inserted above the root post

* Rename variables for clarity
Diffstat (limited to 'src/state/queries/usePostThread/utils.ts')
-rw-r--r--src/state/queries/usePostThread/utils.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/state/queries/usePostThread/utils.ts b/src/state/queries/usePostThread/utils.ts
index b8ab340d8..265bf7f5f 100644
--- a/src/state/queries/usePostThread/utils.ts
+++ b/src/state/queries/usePostThread/utils.ts
@@ -33,6 +33,12 @@ export function getRootPostAtUri(post: AppBskyFeedDefs.PostView) {
       AppBskyFeedPost.isRecord,
     )
   ) {
+    /**
+     * If the record has no `reply` field, it is a root post.
+     */
+    if (!post.record.reply) {
+      return new AtUri(post.uri)
+    }
     if (post.record.reply?.root?.uri) {
       return new AtUri(post.record.reply.root.uri)
     }