diff options
author | Frudrax Cheng <i@cynosura.one> | 2024-06-19 14:41:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 14:41:03 +0800 |
commit | bdc1ea897fa4e1a2bb0fbd405564e98aca36f973 (patch) | |
tree | a412067a09e0c34d7d83496842ebd0e0e57f4b9d /src/state/queries/post-thread.ts | |
parent | a6d49062e6d50b7c9a6c0d50c38fcfeb8f63e46f (diff) | |
parent | 8788708bd229ee8a7049285b2e520cc657b41c00 (diff) | |
download | voidsky-bdc1ea897fa4e1a2bb0fbd405564e98aca36f973.tar.zst |
Merge branch 'bluesky-social:main' into zh
Diffstat (limited to 'src/state/queries/post-thread.ts')
-rw-r--r-- | src/state/queries/post-thread.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index a8b1160fb..db85e8a17 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -31,7 +31,8 @@ import { getEmbeddedPost, } from './util' -const RQKEY_ROOT = 'post-thread' +const REPLY_TREE_DEPTH = 10 +export 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 } } |