Update APIs

This commit is contained in:
Eric Bailey
2025-05-25 13:05:32 -05:00
parent da4afb78d0
commit ef3baf8368
6 changed files with 42 additions and 73 deletions
+12 -22
View File
@@ -5,24 +5,25 @@ import {useLingui} from '@lingui/react'
import {useFocusEffect} from '@react-navigation/native'
import {HITSLOP_10} from '#/lib/constants'
// import {PostThread as PostThreadComponent} from '#/view/com/post-thread/PostThread'
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
import {makeProfileLink} from '#/lib/routes/links'
import {
type CommonNavigatorParams,
type NativeStackScreenProps,
} from '#/lib/routes/types'
import {ScrollProvider} from '#/lib/ScrollContext'
import {cleanError} from '#/lib/strings/errors'
import {makeRecordUri} from '#/lib/strings/url-helpers'
import {isNative} from '#/platform/detection'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostThread as PostThreadComponent} from '#/view/com/post-thread/PostThread'
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
import {ScrollProvider} from '#/lib/ScrollContext'
import {usePreferencesQuery} from '#/state/queries/preferences'
import {
HiddenReplyKind,
type Slice,
usePostThread,
} from '#/state/queries/usePostThread'
import {useSetMinimalShellMode} from '#/state/shell'
import {type OnPostSuccessData} from '#/state/shell/composer'
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
import {PostThreadItem} from '#/view/com/post-thread/PostThreadItem'
@@ -30,21 +31,14 @@ import {PostThreadShowHiddenReplies} from '#/view/com/post-thread/PostThreadShow
import {List, type ListMethods} from '#/view/com/util/List'
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
import {Button, ButtonIcon} from '#/components/Button'
import {Link} from '#/components/Link'
import {makeProfileLink} from '#/lib/routes/links'
import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
import {CirclePlus_Stroke2_Corner0_Rounded as CirclePlus} from '#/components/icons/CirclePlus'
import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
import * as Layout from '#/components/Layout'
import {Link} from '#/components/Link'
import {ListFooter} from '#/components/Lists'
import * as Menu from '#/components/Menu'
import {Text} from '#/components/Typography'
const MAINTAIN_VISIBLE_CONTENT_POSITION = {
// We don't insert any elements before the root row while loading.
// So the row we want to use as the scroll anchor is the first row.
minIndexForVisible: 0,
}
type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'>
export function PostThreadScreen({route}: Props) {
const setMinimalShellMode = useSetMinimalShellMode()
@@ -144,12 +138,12 @@ export function Inner({uri}: {uri: string | undefined}) {
>(new Set())
const {isFetching, error, data, refetch, insertReplies} = usePostThread({
uri,
enabled: isThreadPreferencesLoaded,
params: {
anchor: uri,
sort: sortReplies,
view: treeViewEnabled ? 'tree' : 'linear',
prioritizeFollows: prioritizeFollowedUsers,
prioritizeFollowedUsers,
},
state: {
shownHiddenReplyKinds,
@@ -236,9 +230,7 @@ export function Inner({uri}: {uri: string | undefined}) {
hasMore={false} // TODO need to replace this entirely
showChildReplyLine={item.ui.showChildReplyLine}
showParentReplyLine={item.ui.showParentReplyLine}
hasPrecedingItem={
item.ui.showParentReplyLine
} // !!hasUnrevealedParents // TODO
hasPrecedingItem={item.ui.showParentReplyLine} // !!hasUnrevealedParents // TODO
overrideBlur={
shownHiddenReplyKinds.has(HiddenReplyKind.Muted) && item.depth > 0
}
@@ -358,8 +350,6 @@ export function Inner({uri}: {uri: string | undefined}) {
return null
}
console.log('PostThreadScreen', data?.anchorIndex)
return (
<>
<Layout.Header.Outer headerRef={headerRef}>
@@ -400,7 +390,7 @@ export function Inner({uri}: {uri: string | undefined}) {
*/
maintainVisibleContentPosition={
isNative // && hasParents // TODO not sure we need this
? { minIndexForVisible: 0 } // MAINTAIN_VISIBLE_CONTENT_POSITION
? {minIndexForVisible: 0} // MAINTAIN_VISIBLE_CONTENT_POSITION
: undefined
}
desktopFixedHeight