Fix orphan replies in linear mode (#2578)
parent
d25b17ab19
commit
21846ce52d
|
@ -157,7 +157,11 @@ function PostThreadLoaded({
|
||||||
const posts = React.useMemo(() => {
|
const posts = React.useMemo(() => {
|
||||||
let arr = [TOP_COMPONENT].concat(
|
let arr = [TOP_COMPONENT].concat(
|
||||||
Array.from(
|
Array.from(
|
||||||
flattenThreadSkeleton(sortThread(thread, threadViewPrefs), hasSession),
|
flattenThreadSkeleton(
|
||||||
|
sortThread(thread, threadViewPrefs),
|
||||||
|
hasSession,
|
||||||
|
treeView,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if (arr.length > maxVisible) {
|
if (arr.length > maxVisible) {
|
||||||
|
@ -167,7 +171,7 @@ function PostThreadLoaded({
|
||||||
arr.push(BOTTOM_COMPONENT)
|
arr.push(BOTTOM_COMPONENT)
|
||||||
}
|
}
|
||||||
return arr
|
return arr
|
||||||
}, [thread, maxVisible, threadViewPrefs, hasSession])
|
}, [thread, treeView, maxVisible, threadViewPrefs, hasSession])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE
|
* NOTE
|
||||||
|
@ -486,10 +490,11 @@ function isThreadPost(v: unknown): v is ThreadPost {
|
||||||
function* flattenThreadSkeleton(
|
function* flattenThreadSkeleton(
|
||||||
node: ThreadNode,
|
node: ThreadNode,
|
||||||
hasSession: boolean,
|
hasSession: boolean,
|
||||||
|
treeView: boolean,
|
||||||
): Generator<YieldedItem, void> {
|
): Generator<YieldedItem, void> {
|
||||||
if (node.type === 'post') {
|
if (node.type === 'post') {
|
||||||
if (node.parent) {
|
if (node.parent) {
|
||||||
yield* flattenThreadSkeleton(node.parent, hasSession)
|
yield* flattenThreadSkeleton(node.parent, hasSession, treeView)
|
||||||
} else if (node.ctx.isParentLoading) {
|
} else if (node.ctx.isParentLoading) {
|
||||||
yield PARENT_SPINNER
|
yield PARENT_SPINNER
|
||||||
}
|
}
|
||||||
|
@ -502,7 +507,10 @@ function* flattenThreadSkeleton(
|
||||||
}
|
}
|
||||||
if (node.replies?.length) {
|
if (node.replies?.length) {
|
||||||
for (const reply of node.replies) {
|
for (const reply of node.replies) {
|
||||||
yield* flattenThreadSkeleton(reply, hasSession)
|
yield* flattenThreadSkeleton(reply, hasSession, treeView)
|
||||||
|
if (!treeView && !node.ctx.isHighlightedPost) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (node.ctx.isChildLoading) {
|
} else if (node.ctx.isChildLoading) {
|
||||||
yield CHILD_SPINNER
|
yield CHILD_SPINNER
|
||||||
|
|
Loading…
Reference in New Issue