Add profile loading shim (#1940)
parent
22df70b3cc
commit
f89dc63801
|
@ -11,12 +11,14 @@ import {s} from 'lib/styles'
|
||||||
import {useModerationOpts} from '#/state/queries/preferences'
|
import {useModerationOpts} from '#/state/queries/preferences'
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
import {ErrorScreen} from '../util/error/ErrorScreen'
|
import {ErrorScreen} from '../util/error/ErrorScreen'
|
||||||
|
import {CenteredView} from '../util/Views'
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
|
|
||||||
export const snapPoints = [520, '100%']
|
export const snapPoints = [520, '100%']
|
||||||
|
|
||||||
export function Component({did}: {did: string}) {
|
export function Component({did}: {did: string}) {
|
||||||
|
const pal = usePalette('default')
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const {
|
const {
|
||||||
data: profile,
|
data: profile,
|
||||||
|
@ -30,9 +32,13 @@ export function Component({did}: {did: string}) {
|
||||||
|
|
||||||
if (isFetchingProfile || !moderationOpts) {
|
if (isFetchingProfile || !moderationOpts) {
|
||||||
return (
|
return (
|
||||||
<View style={s.p20}>
|
<CenteredView style={[pal.view, s.flex1]}>
|
||||||
<ActivityIndicator size="large" />
|
<ProfileHeader
|
||||||
</View>
|
profile={null}
|
||||||
|
moderation={null}
|
||||||
|
isProfilePreview={true}
|
||||||
|
/>
|
||||||
|
</CenteredView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (profileError) {
|
if (profileError) {
|
||||||
|
|
|
@ -53,8 +53,8 @@ import {useSession} from '#/state/session'
|
||||||
import {Shadow} from '#/state/cache/types'
|
import {Shadow} from '#/state/cache/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed> | null
|
||||||
moderation: ProfileModeration
|
moderation: ProfileModeration | null
|
||||||
hideBackButton?: boolean
|
hideBackButton?: boolean
|
||||||
isProfilePreview?: boolean
|
isProfilePreview?: boolean
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ export function ProfileHeader({
|
||||||
|
|
||||||
// loading
|
// loading
|
||||||
// =
|
// =
|
||||||
if (!profile) {
|
if (!profile || !moderation) {
|
||||||
return (
|
return (
|
||||||
<View style={pal.view}>
|
<View style={pal.view}>
|
||||||
<LoadingPlaceholder width="100%" height={153} />
|
<LoadingPlaceholder width="100%" height={153} />
|
||||||
|
@ -81,11 +81,6 @@ export function ProfileHeader({
|
||||||
<View style={[styles.buttonsLine]}>
|
<View style={[styles.buttonsLine]}>
|
||||||
<LoadingPlaceholder width={167} height={31} style={styles.br50} />
|
<LoadingPlaceholder width={167} height={31} style={styles.br50} />
|
||||||
</View>
|
</View>
|
||||||
<View>
|
|
||||||
<Text type="title-2xl" style={[pal.text, styles.title]}>
|
|
||||||
<Trans>Loading...</Trans>
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
@ -103,12 +98,19 @@ export function ProfileHeader({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface LoadedProps {
|
||||||
|
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
||||||
|
moderation: ProfileModeration
|
||||||
|
hideBackButton?: boolean
|
||||||
|
isProfilePreview?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
function ProfileHeaderLoaded({
|
function ProfileHeaderLoaded({
|
||||||
profile,
|
profile,
|
||||||
moderation,
|
moderation,
|
||||||
hideBackButton = false,
|
hideBackButton = false,
|
||||||
isProfilePreview,
|
isProfilePreview,
|
||||||
}: Props) {
|
}: LoadedProps) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const palInverted = usePalette('inverted')
|
const palInverted = usePalette('inverted')
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, {useMemo} from 'react'
|
import React, {useMemo} from 'react'
|
||||||
import {ActivityIndicator, StyleSheet, View} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {useFocusEffect} from '@react-navigation/native'
|
import {useFocusEffect} from '@react-navigation/native'
|
||||||
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
|
@ -73,9 +73,11 @@ export const ProfileScreen = withAuthRequired(function ProfileScreenImpl({
|
||||||
if (isFetchingDid || isFetchingProfile || !moderationOpts) {
|
if (isFetchingDid || isFetchingProfile || !moderationOpts) {
|
||||||
return (
|
return (
|
||||||
<CenteredView>
|
<CenteredView>
|
||||||
<View style={s.p20}>
|
<ProfileHeader
|
||||||
<ActivityIndicator size="large" />
|
profile={null}
|
||||||
</View>
|
moderation={null}
|
||||||
|
isProfilePreview={true}
|
||||||
|
/>
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -158,12 +160,6 @@ function ProfileScreenLoaded({
|
||||||
].filter(Boolean) as string[]
|
].filter(Boolean) as string[]
|
||||||
}, [showLikesTab, showFeedsTab, showListsTab])
|
}, [showLikesTab, showFeedsTab, showListsTab])
|
||||||
|
|
||||||
/*
|
|
||||||
- todo
|
|
||||||
- feeds
|
|
||||||
- lists
|
|
||||||
*/
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
setMinimalShellMode(false)
|
setMinimalShellMode(false)
|
||||||
|
|
Loading…
Reference in New Issue