From 00e1e56a7d3f1c7f6f3160999e8022c0429963f4 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 6 Dec 2023 22:17:38 -0800 Subject: [PATCH] Treeview: more UI tweaks (#2125) * Treeview: more UI tweaks * Only show treeview when there are branching replies * Fix types --- src/view/com/post-thread/PostThread.tsx | 21 +++++++++++++++++++-- src/view/com/post-thread/PostThreadItem.tsx | 17 +++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 22438fc797..cf43d2055f 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({ 0 const isThreadedChildAdjacentTop = - isThreadedChild && prevPost?.ctx.depth === depth + isThreadedChild && prevPost?.ctx.depth === depth && depth !== 1 const isThreadedChildAdjacentBot = isThreadedChild && nextPost?.ctx.depth === depth return ( - {Array.from(Array(depth)).map((_, n: number) => ( + {Array.from(Array(depth - 1)).map((_, n: number) => ( ))}