about summary refs log tree commit diff
path: root/src/view/com/post-thread/PostThread.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/com/post-thread/PostThread.tsx')
-rw-r--r--src/view/com/post-thread/PostThread.tsx21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx
index 22438fc79..cf43d2055 100644
--- a/src/view/com/post-thread/PostThread.tsx
+++ b/src/view/com/post-thread/PostThread.tsx
@@ -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,