Treeview: more UI tweaks (#2125)
* Treeview: more UI tweaks * Only show treeview when there are branching replies * Fix types
This commit is contained in:
parent
818c6ae879
commit
00e1e56a7d
2 changed files with 26 additions and 12 deletions
|
@ -141,6 +141,10 @@ function PostThreadLoaded({
|
|||
)
|
||||
const [maxVisible, setMaxVisible] = React.useState(100)
|
||||
const [isPTRing, setIsPTRing] = React.useState(false)
|
||||
const treeView = React.useMemo(
|
||||
() => !!threadViewPrefs.lab_treeViewEnabled && hasBranchingReplies(thread),
|
||||
[threadViewPrefs, thread],
|
||||
)
|
||||
|
||||
// construct content
|
||||
const posts = React.useMemo(() => {
|
||||
|
@ -289,7 +293,7 @@ function PostThreadLoaded({
|
|||
<PostThreadItem
|
||||
post={item.post}
|
||||
record={item.record}
|
||||
treeView={threadViewPrefs.lab_treeViewEnabled || false}
|
||||
treeView={treeView}
|
||||
depth={item.ctx.depth}
|
||||
prevPost={prev}
|
||||
nextPost={next}
|
||||
|
@ -318,7 +322,7 @@ function PostThreadLoaded({
|
|||
pal.colors.border,
|
||||
posts,
|
||||
onRefresh,
|
||||
threadViewPrefs.lab_treeViewEnabled,
|
||||
treeView,
|
||||
_,
|
||||
],
|
||||
)
|
||||
|
@ -481,6 +485,19 @@ function* flattenThreadSkeleton(
|
|||
}
|
||||
}
|
||||
|
||||
function hasBranchingReplies(node: ThreadNode) {
|
||||
if (node.type !== 'post') {
|
||||
return false
|
||||
}
|
||||
if (!node.replies) {
|
||||
return false
|
||||
}
|
||||
if (node.replies.length === 1) {
|
||||
return hasBranchingReplies(node.replies[0])
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
notFoundContainer: {
|
||||
margin: 10,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue