about summary refs log tree commit diff
path: root/src/state
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-06-18 11:48:49 -0700
committerGitHub <noreply@github.com>2024-06-18 21:48:49 +0300
commitfb76265fcc0042bc8cd5a3f7563790f495d3ae8c (patch)
tree728267ec7aa979a4d94b12051d0531048fa2ab9d /src/state
parent5f5d845053e13169f89fc70a3f858b0a9e5ed4fd (diff)
downloadvoidsky-fb76265fcc0042bc8cd5a3f7563790f495d3ae8c.tar.zst
Fix: only apply self-thread load-more behavior on the outer edge of the reply tree (#4559)
Diffstat (limited to 'src/state')
-rw-r--r--src/state/queries/post-thread.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts
index a8b1160fb..f7e5e2ecb 100644
--- a/src/state/queries/post-thread.ts
+++ b/src/state/queries/post-thread.ts
@@ -31,6 +31,7 @@ import {
   getEmbeddedPost,
 } from './util'
 
+const REPLY_TREE_DEPTH = 10
 const RQKEY_ROOT = 'post-thread'
 export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
 type ThreadViewNode = AppBskyFeedGetPostThread.OutputSchema['thread']
@@ -90,7 +91,10 @@ export function usePostThreadQuery(uri: string | undefined) {
     gcTime: 0,
     queryKey: RQKEY(uri || ''),
     async queryFn() {
-      const res = await agent.getPostThread({uri: uri!, depth: 10})
+      const res = await agent.getPostThread({
+        uri: uri!,
+        depth: REPLY_TREE_DEPTH,
+      })
       if (res.success) {
         const thread = responseToThreadNodes(res.data.thread)
         annotateSelfThread(thread)
@@ -287,7 +291,12 @@ function annotateSelfThread(thread: ThreadNode) {
       selfThreadNode.ctx.isSelfThread = true
     }
     const last = selfThreadNodes[selfThreadNodes.length - 1]
-    if (last && last.post.replyCount && !last.replies?.length) {
+    if (
+      last &&
+      last.ctx.depth === REPLY_TREE_DEPTH && // at the edge of the tree depth
+      last.post.replyCount && // has replies
+      !last.replies?.length // replies were not hydrated
+    ) {
       last.ctx.hasMoreSelfThread = true
     }
   }