diff options
author | Eric Bailey <git@esb.lol> | 2023-09-20 11:03:57 -0500 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2023-09-20 11:03:57 -0500 |
commit | 5665968f729b99509d54769f494bbbfc59b4b630 (patch) | |
tree | bfad6f82b613699ba3f206d460f0eac50dee6bd4 /src/view/com/post-thread/PostThread.tsx | |
parent | 63527493fd8dfb72d21bd50cd2404a5cf2c6e274 (diff) | |
parent | cd96f8dcc8692aec4b9b165cc9f47d7e0b6257df (diff) | |
download | voidsky-5665968f729b99509d54769f494bbbfc59b4b630.tar.zst |
Merge remote-tracking branch 'origin' into bnewbold/bump-api-dep
* origin: Allow touch at the top of the lightbox (#1489) Bump ios build number Feeds tab fixes (#1486) Nicer 'post processing status' in the composer (#1472) Inline createPanResponder (#1483) Tree view threads experiment (#1480) Make "double tap to zoom" precise across platforms (#1482) Onboarding recommended follows (#1457) Add thread sort settings (#1475)
Diffstat (limited to 'src/view/com/post-thread/PostThread.tsx')
-rw-r--r-- | src/view/com/post-thread/PostThread.tsx | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 1cc177d17..373b4499d 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -55,6 +55,7 @@ const LOAD_MORE = { const BOTTOM_COMPONENT = { _reactKey: '__bottom_component__', _isHighlightedPost: false, + _showBorder: true, } type YieldedItem = | PostThreadItemModel @@ -69,10 +70,12 @@ export const PostThread = observer(function PostThread({ uri, view, onPressReply, + treeView, }: { uri: string view: PostThreadModel onPressReply: () => void + treeView: boolean }) { const pal = usePalette('default') const {isTablet} = useWebMediaQueries() @@ -99,6 +102,13 @@ export const PostThread = observer(function PostThread({ } return [] }, [view.isLoadingFromCache, view.thread, maxVisible]) + const highlightedPostIndex = posts.findIndex(post => post._isHighlightedPost) + const showBottomBorder = + !treeView || + // in the treeview, only show the bottom border + // if there are replies under the highlighted posts + posts.findLast(v => v instanceof PostThreadItemModel) !== + posts[highlightedPostIndex] useSetTitle( view.thread?.postRecord && `${sanitizeDisplayName( @@ -135,17 +145,16 @@ export const PostThread = observer(function PostThread({ return } - const index = posts.findIndex(post => post._isHighlightedPost) - if (index !== -1) { + if (highlightedPostIndex !== -1) { ref.current?.scrollToIndex({ - index, + index: highlightedPostIndex, animated: false, viewPosition: 0, }) hasScrolledIntoView.current = true } }, [ - posts, + highlightedPostIndex, view.hasContent, view.isFromCache, view.isLoadingFromCache, @@ -184,7 +193,14 @@ export const PostThread = observer(function PostThread({ </View> ) } else if (item === REPLY_PROMPT) { - return <ComposePrompt onPressCompose={onPressReply} /> + return ( + <View + style={ + treeView && [pal.border, {borderBottomWidth: 1, marginBottom: 6}] + }> + {isDesktopWeb && <ComposePrompt onPressCompose={onPressReply} />} + </View> + ) } else if (item === DELETED) { return ( <View style={[pal.border, pal.viewLight, styles.itemContainer]}> @@ -224,7 +240,18 @@ export const PostThread = observer(function PostThread({ // due to some complexities with how flatlist works, this is the easiest way // I could find to get a border positioned directly under the last item // -prf - return <View style={[pal.border, styles.bottomSpacer]} /> + return ( + <View + style={[ + {height: 400}, + showBottomBorder && { + borderTopWidth: 1, + borderColor: pal.colors.border, + }, + treeView && {marginTop: 10}, + ]} + /> + ) } else if (item === CHILD_SPINNER) { return ( <View style={styles.childSpinner}> @@ -240,12 +267,13 @@ export const PostThread = observer(function PostThread({ item={item} onPostReply={onRefresh} hasPrecedingItem={prev?._showChildReplyLine} + treeView={treeView} /> ) } return <></> }, - [onRefresh, onPressReply, pal, posts, isTablet], + [onRefresh, onPressReply, pal, posts, isTablet, treeView, showBottomBorder], ) // loading @@ -377,7 +405,7 @@ function* flattenThread( } } yield post - if (isDesktopWeb && post._isHighlightedPost) { + if (post._isHighlightedPost) { yield REPLY_PROMPT } if (post.replies?.length) { @@ -411,8 +439,4 @@ const styles = StyleSheet.create({ paddingVertical: 10, }, childSpinner: {}, - bottomSpacer: { - height: 400, - borderTopWidth: 1, - }, }) |