From 25ee588e27684a2e0c2ace5affa7cc1514979e4a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 4 Jun 2025 19:47:34 -0500 Subject: [PATCH] Make optimistic deleted state not look like crap in tree view --- .../PostThread/components/ThreadReply.tsx | 378 ++++++++++-------- 1 file changed, 217 insertions(+), 161 deletions(-) diff --git a/src/screens/PostThread/components/ThreadReply.tsx b/src/screens/PostThread/components/ThreadReply.tsx index 274d253bff..0e087325c6 100644 --- a/src/screens/PostThread/components/ThreadReply.tsx +++ b/src/screens/PostThread/components/ThreadReply.tsx @@ -66,7 +66,7 @@ export function ThreadReply({ const postShadow = usePostShadow(item.value.post) if (postShadow === POST_TOMBSTONE) { - return + return } return ( @@ -82,26 +82,157 @@ export function ThreadReply({ ) } -function PostThreadItemDeleted({hideTopBorder}: {hideTopBorder?: boolean}) { +function ThreadItemTreeReplyDeleted({ + item, +}: { + item: Extract +}) { + const t = useTheme() + return ( + + + + + + This post has been deleted. + + + {item.ui.isLastChild && !item.ui.precedesChildReadMore && ( + + )} + + + ) +} + +const ThreadItemTreeReplyOuter = memo(function ThreadItemTreeReplyOuter({ + item, + children, +}: { + item: Extract + children: React.ReactNode +}) { + const t = useTheme() + const indents = Math.max(0, item.ui.indent - 1) + + return ( + + {Array.from(Array(indents)).map((_, n: number) => { + const isSkipped = item.ui.skippedIndentIndices.has(n) + return ( + + ) + })} + {children} + + ) +}) + +const ThreadItemTreeReplyInner = memo(function ThreadItemTreeReplyInner({ + item, + children, +}: { + item: Extract + children: React.ReactNode +}) { const t = useTheme() return ( - - - This post has been deleted. - + {item.ui.indent > 1 && ( + + )} + {children} ) -} +}) + +const ThreadItemTreeReplyChildReplyLine = memo( + function ThreadItemTreeReplyChildReplyLine({ + item, + }: { + item: Extract + }) { + const t = useTheme() + return ( + + {item.ui.showChildReplyLine && ( + + )} + + ) + }, +) const ThreadReplyInner = memo(function ThreadReplyInner({ item, @@ -119,7 +250,6 @@ const ThreadReplyInner = memo(function ThreadReplyInner({ onPostSuccess?: (data: OnPostSuccessData) => void threadgateRecord?: AppBskyFeedThreadgate.Record }): React.ReactNode { - const t = useTheme() const pal = usePalette('default') const {_} = useLingui() const {openComposer} = useOpenComposer() @@ -180,160 +310,86 @@ const ThreadReplyInner = memo(function ThreadReplyInner({ setLimitLines(false) }, [setLimitLines]) - const indents = Math.max(0, item.ui.indent - 1) - return ( - - {Array.from(Array(indents)).map((_, n: number) => { - const isSkipped = item.ui.skippedIndentIndices.has(n) - return ( - - ) - })} - - - - - {item.ui.indent > 1 && ( - + + + + + + - )} - - - - - - {item.ui.showChildReplyLine && ( - + + + + + {richText?.text ? ( + + - )} - - - - + ) : undefined} + {limitLines ? ( + - {richText?.text ? ( - - - - ) : undefined} - {limitLines ? ( - + - ) : undefined} - {post.embed && ( - - - - )} - - + + )} + - - - - + + + + ) }) @@ -347,7 +403,7 @@ function SubtleHover({children}: {children: React.ReactNode}) { + style={[a.flex_1, a.pointer]}> {children}