From 7360f6b851927bdb7989363965fffdeda9409433 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 4 Jun 2025 21:19:59 -0500 Subject: [PATCH] Handle tombstone views --- .../components/ThreadItemPostTombstone.tsx | 63 +++++++++++++++++++ src/screens/PostThread/index.tsx | 43 ++++--------- 2 files changed, 76 insertions(+), 30 deletions(-) create mode 100644 src/screens/PostThread/components/ThreadItemPostTombstone.tsx diff --git a/src/screens/PostThread/components/ThreadItemPostTombstone.tsx b/src/screens/PostThread/components/ThreadItemPostTombstone.tsx new file mode 100644 index 0000000000..d6e7a03c49 --- /dev/null +++ b/src/screens/PostThread/components/ThreadItemPostTombstone.tsx @@ -0,0 +1,63 @@ +import {useMemo} from 'react' +import {View} from 'react-native' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {LINEAR_AVI_WIDTH, OUTER_SPACE} from '#/screens/PostThread/const' +import {atoms as a, useTheme} from '#/alf' +import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash' +import {Text} from '#/components/Typography' + +export type ThreadItemPostTombstoneProps = { + type: 'not-found' | 'blocked' +} + +export function ThreadItemPostTombstone({type}: ThreadItemPostTombstoneProps) { + const t = useTheme() + const {_} = useLingui() + const copy = useMemo(() => { + switch (type) { + case 'blocked': + return _(msg`Post blocked.`) + case 'not-found': + default: + return _(msg`Post not found.`) + } + }, [_, type]) + + return ( + + + + + + + {copy} + + + + ) +} diff --git a/src/screens/PostThread/index.tsx b/src/screens/PostThread/index.tsx index e17d9e0047..f7628b5792 100644 --- a/src/screens/PostThread/index.tsx +++ b/src/screens/PostThread/index.tsx @@ -23,17 +23,16 @@ import { ThreadItemPost, ThreadItemPostSkeleton, } from '#/screens/PostThread/components/ThreadItemPost' +import {ThreadItemPostTombstone} from '#/screens/PostThread/components/ThreadItemPostTombstone' import {ThreadItemTreePost} from '#/screens/PostThread/components/ThreadItemTreePost' -import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' +import {useBreakpoints, web} from '#/alf' import * as Layout from '#/components/Layout' import {ListFooter} from '#/components/Lists' -import {Text} from '#/components/Typography' const PARENT_CHUNK_SIZE = 5 const CHILDREN_CHUNK_SIZE = 50 export function Inner({uri}: {uri: string | undefined}) { - const t = useTheme() const {gtPhone} = useBreakpoints() // const {hasSession, currentAccount} = useSession() const initialNumToRender = useInitialNumToRender() @@ -205,6 +204,13 @@ export function Inner({uri}: {uri: string | undefined}) { return results }, [thread, deferParents, maxParentCount, maxChildrenCount]) + const isTombstoneView = useMemo(() => { + if (slices.length > 1) return false + return slices.every( + s => s.type === 'threadPostBlocked' || s.type === 'threadPostNotFound', + ) + }, [slices]) + const renderItem = ({item, index}: {item: ThreadItem; index: number}) => { if (item.type === 'threadPost') { if (item.depth < 0) { @@ -214,7 +220,7 @@ export function Inner({uri}: {uri: string | undefined}) { item={item} threadgateRecord={thread.data.threadgate?.record ?? undefined} overrides={{ - topBorder: index === 0, // && !item.isParentLoading, // TODO + topBorder: index === 0, }} onPostSuccess={optimisticOnPostReply} /> @@ -266,33 +272,9 @@ export function Inner({uri}: {uri: string | undefined}) { /> ) } else if (item.type === 'threadPostBlocked') { - return ( - - - Blocked post. - - - ) + return } else if (item.type === 'threadPostNotFound') { - return ( - - - Deleted post. - - - ) + return } else if (item.type === 'replyComposer') { return ( @@ -386,6 +368,7 @@ export function Inner({uri}: {uri: string | undefined}) { * causing weird jumps on web or glitches on native */ height={windowHeight - 200} + style={isTombstoneView ? {borderTopWidth: 0} : undefined} /> } initialNumToRender={initialNumToRender}