Rough handling of hidden/muted

This commit is contained in:
Eric Bailey
2025-05-06 18:52:46 -05:00
parent e42cd77fc0
commit df607870f0
2 changed files with 115 additions and 66 deletions
+19 -7
View File
@@ -16,7 +16,7 @@ import * as Layout from '#/components/Layout'
import {useSession} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {useGetPostThreadV2, Slice} from '#/state/queries/useGetPostThreadV2'
import {useGetPostThreadV2, Slice, HiddenReplyKind} from '#/state/queries/useGetPostThreadV2'
import * as Menu from '#/components/Menu'
import {Button, ButtonIcon} from '#/components/Button'
import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
@@ -28,6 +28,7 @@ import {PostThreadItem} from '#/view/com/post-thread/PostThreadItem'
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
import {usePreferencesQuery} from '#/state/queries/preferences'
import {useComposerControls} from '#/state/shell'
import {PostThreadShowHiddenReplies} from '#/view/com/post-thread/PostThreadShowHiddenReplies'
const MAINTAIN_VISIBLE_CONTENT_POSITION = {
// We don't insert any elements before the root row while loading.
@@ -126,14 +127,20 @@ export function Inner({uri}: {uri: string | undefined}) {
setTreeViewEnabled,
} = useThreadPreferences()
const [showHiddenReplies, setShowHiddenReplies] = useState<HiddenReplyKind | null>(null)
const [shownHiddenReplyKinds, setShownHiddenReplyKinds] = useState<Set<HiddenReplyKind>>(new Set())
const {isFetching, isPlaceholderData, error, data, refetch} = useGetPostThreadV2({
uri,
enabled: isThreadPreferencesLoaded,
options: {
params: {
sort: sortReplies,
view: treeViewEnabled ? 'tree' : 'linear',
prioritizeFollows: prioritizeFollowedUsers,
},
state: {
shownHiddenReplyKinds,
}
})
const ref = useRef<ListMethods>(null)
@@ -199,11 +206,9 @@ export function Inner({uri}: {uri: string | undefined}) {
hasPrecedingItem={
item.ui.showParentReplyLine || !!item.slice.hasUnhydratedParents
} // !!hasUnrevealedParents // TODO
// overrideBlur={
// hiddenRepliesState ===
// HiddenRepliesState.ShowAndOverridePostHider &&
// item.ctx.depth > 0
// }
overrideBlur={
shownHiddenReplyKinds.has(HiddenReplyKind.Muted) && item.slice.depth > 0
}
onPostReply={onPostReply}
hideTopBorder={index === 0} // && !item.slice.isParentLoading} // TODO
/>
@@ -215,6 +220,13 @@ export function Inner({uri}: {uri: string | undefined}) {
{gtPhone && <PostThreadComposePrompt onPressCompose={onReplyToAnchor} />}
</View>
)
} else if (item.type === 'showHiddenReplies') {
return (
<PostThreadShowHiddenReplies
type={item.kind === 'muted' ? 'muted' : 'hidden'}
onPress={() => setShownHiddenReplyKinds(kinds => new Set([...kinds, item.kind]))}
/>
)
}
return null
}