Fix to thread load-more bug (#4488)

zio/stable
Paul Frazee 2024-06-11 15:01:13 -07:00 committed by GitHub
parent a4ca4db35c
commit e1dcd2e434
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 3 deletions

View File

@ -94,7 +94,6 @@ export function usePostThreadQuery(uri: string | undefined) {
if (res.success) { if (res.success) {
const thread = responseToThreadNodes(res.data.thread) const thread = responseToThreadNodes(res.data.thread)
annotateSelfThread(thread) annotateSelfThread(thread)
console.log(thread)
return thread return thread
} }
return {type: 'unknown', uri: uri!} return {type: 'unknown', uri: uri!}
@ -267,7 +266,7 @@ function annotateSelfThread(thread: ThreadNode) {
// not a self-thread // not a self-thread
return return
} }
selfThreadNodes.push(parent) selfThreadNodes.unshift(parent)
parent = parent.parent parent = parent.parent
} }
@ -287,7 +286,7 @@ function annotateSelfThread(thread: ThreadNode) {
for (const selfThreadNode of selfThreadNodes) { for (const selfThreadNode of selfThreadNodes) {
selfThreadNode.ctx.isSelfThread = true selfThreadNode.ctx.isSelfThread = true
} }
const last = selfThreadNodes.at(-1) const last = selfThreadNodes[selfThreadNodes.length - 1]
if (last && last.post.replyCount && !last.replies?.length) { if (last && last.post.replyCount && !last.replies?.length) {
last.ctx.hasMoreSelfThread = true last.ctx.hasMoreSelfThread = true
} }