ProfileFeed cleanups (#7115)

* Clean up feed load state

* Fix feed info dialog load state
This commit is contained in:
Eric Bailey
2024-12-14 15:30:01 -06:00
committed by GitHub
parent b806f3e85d
commit c959dc351f
2 changed files with 56 additions and 18 deletions
+16 -5
View File
@@ -34,9 +34,12 @@ import {FAB} from '#/view/com/util/fab/FAB'
import {Button} from '#/view/com/util/forms/Button' import {Button} from '#/view/com/util/forms/Button'
import {ListRef} from '#/view/com/util/List' import {ListRef} from '#/view/com/util/List'
import {LoadLatestBtn} from '#/view/com/util/load-latest/LoadLatestBtn' import {LoadLatestBtn} from '#/view/com/util/load-latest/LoadLatestBtn'
import {LoadingScreen} from '#/view/com/util/LoadingScreen' import {PostFeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ProfileFeedHeader} from '#/screens/Profile/components/ProfileFeedHeader' import {
ProfileFeedHeader,
ProfileFeedHeaderSkeleton,
} from '#/screens/Profile/components/ProfileFeedHeader'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFeed'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFeed'>
@@ -92,12 +95,15 @@ export function ProfileFeedScreen(props: Props) {
} }
return resolvedUri ? ( return resolvedUri ? (
<Layout.Screen noInsetTop> <Layout.Screen>
<ProfileFeedScreenIntermediate feedUri={resolvedUri.uri} /> <ProfileFeedScreenIntermediate feedUri={resolvedUri.uri} />
</Layout.Screen> </Layout.Screen>
) : ( ) : (
<Layout.Screen> <Layout.Screen>
<LoadingScreen /> <Layout.Content>
<ProfileFeedHeaderSkeleton />
<PostFeedLoadingPlaceholder />
</Layout.Content>
</Layout.Screen> </Layout.Screen>
) )
} }
@@ -107,7 +113,12 @@ function ProfileFeedScreenIntermediate({feedUri}: {feedUri: string}) {
const {data: info} = useFeedSourceInfoQuery({uri: feedUri}) const {data: info} = useFeedSourceInfoQuery({uri: feedUri})
if (!preferences || !info) { if (!preferences || !info) {
return <LoadingScreen /> return (
<Layout.Content>
<ProfileFeedHeaderSkeleton />
<PostFeedLoadingPlaceholder />
</Layout.Content>
)
} }
return ( return (
@@ -1,6 +1,5 @@
import React from 'react' import React from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {useSafeAreaInsets} from 'react-native-safe-area-context'
import {AtUri} from '@atproto/api' import {AtUri} from '@atproto/api'
import {msg, Plural, Trans} from '@lingui/macro' import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
@@ -46,18 +45,53 @@ import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
import {InlineLinkText} from '#/components/Link' import {InlineLinkText} from '#/components/Link'
import {Loader} from '#/components/Loader'
import * as Menu from '#/components/Menu' import * as Menu from '#/components/Menu'
import {ReportDialog, useReportDialogControl} from '#/components/ReportDialog' import {ReportDialog, useReportDialogControl} from '#/components/ReportDialog'
import {RichText} from '#/components/RichText' import {RichText} from '#/components/RichText'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
export function ProfileFeedHeaderSkeleton() {
const t = useTheme()
return (
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
<View
style={[
a.w_full,
a.rounded_sm,
t.atoms.bg_contrast_25,
{
height: 44,
},
]}
/>
</Layout.Header.Content>
<Layout.Header.Slot>
<View
style={[
a.justify_center,
a.align_center,
a.rounded_full,
t.atoms.bg_contrast_25,
{
height: 34,
width: 34,
},
]}>
<Pin size="lg" fill={t.atoms.text_contrast_low.color} />
</View>
</Layout.Header.Slot>
</Layout.Header.Outer>
)
}
export function ProfileFeedHeader({info}: {info: FeedSourceFeedInfo}) { export function ProfileFeedHeader({info}: {info: FeedSourceFeedInfo}) {
const t = useTheme() const t = useTheme()
const {_, i18n} = useLingui() const {_, i18n} = useLingui()
const {hasSession} = useSession() const {hasSession} = useSession()
const {gtPhone, gtMobile} = useBreakpoints() const {gtPhone, gtMobile} = useBreakpoints()
const {top} = useSafeAreaInsets()
const infoControl = Dialog.useDialogControl() const infoControl = Dialog.useDialogControl()
const playHaptic = useHaptics() const playHaptic = useHaptics()
@@ -148,12 +182,7 @@ export function ProfileFeedHeader({info}: {info: FeedSourceFeedInfo}) {
return ( return (
<> <>
<Layout.Center <Layout.Center
style={[ style={[t.atoms.bg, a.z_10, web([a.sticky, a.z_10, {top: 0}])]}>
t.atoms.bg,
a.z_10,
{paddingTop: top},
web([a.sticky, a.z_10, {top: 0}]),
]}>
<Layout.Header.Outer> <Layout.Header.Outer>
<Layout.Header.BackButton /> <Layout.Header.BackButton />
<Layout.Header.Content align="left"> <Layout.Header.Content align="left">
@@ -356,7 +385,7 @@ function DialogInner({
const playHaptic = useHaptics() const playHaptic = useHaptics()
const control = Dialog.useDialogContext() const control = Dialog.useDialogContext()
const reportDialogControl = useReportDialogControl() const reportDialogControl = useReportDialogControl()
const [rt, loading] = useRichText(info.description.text) const [rt] = useRichText(info.description.text)
const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation() const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation()
const {mutateAsync: unlikeFeed, isPending: isUnlikePending} = const {mutateAsync: unlikeFeed, isPending: isUnlikePending} =
useUnlikeMutation() useUnlikeMutation()
@@ -396,9 +425,7 @@ function DialogInner({
reportDialogControl.open() reportDialogControl.open()
}, [reportDialogControl]) }, [reportDialogControl])
return loading ? ( return (
<Loader size="xl" />
) : (
<View style={[a.gap_md]}> <View style={[a.gap_md]}>
<View style={[a.flex_row, a.align_center, a.gap_md]}> <View style={[a.flex_row, a.align_center, a.gap_md]}>
<UserAvatar type="algo" size={48} avatar={info.avatar} /> <UserAvatar type="algo" size={48} avatar={info.avatar} />