Bluesky app fork with some witchin' additions 💫

Add profile loading shim (#1940)

authored by danabra.mov and committed by

GitHub f89dc638 22df70b3

+26 -22
+9 -3
src/view/com/modals/ProfilePreview.tsx
··· 11 11 import {useModerationOpts} from '#/state/queries/preferences' 12 12 import {useProfileQuery} from '#/state/queries/profile' 13 13 import {ErrorScreen} from '../util/error/ErrorScreen' 14 + import {CenteredView} from '../util/Views' 14 15 import {cleanError} from '#/lib/strings/errors' 15 16 import {useProfileShadow} from '#/state/cache/profile-shadow' 16 17 17 18 export const snapPoints = [520, '100%'] 18 19 19 20 export function Component({did}: {did: string}) { 21 + const pal = usePalette('default') 20 22 const moderationOpts = useModerationOpts() 21 23 const { 22 24 data: profile, ··· 30 32 31 33 if (isFetchingProfile || !moderationOpts) { 32 34 return ( 33 - <View style={s.p20}> 34 - <ActivityIndicator size="large" /> 35 - </View> 35 + <CenteredView style={[pal.view, s.flex1]}> 36 + <ProfileHeader 37 + profile={null} 38 + moderation={null} 39 + isProfilePreview={true} 40 + /> 41 + </CenteredView> 36 42 ) 37 43 } 38 44 if (profileError) {
+11 -9
src/view/com/profile/ProfileHeader.tsx
··· 53 53 import {Shadow} from '#/state/cache/types' 54 54 55 55 interface Props { 56 - profile: Shadow<AppBskyActorDefs.ProfileViewDetailed> 57 - moderation: ProfileModeration 56 + profile: Shadow<AppBskyActorDefs.ProfileViewDetailed> | null 57 + moderation: ProfileModeration | null 58 58 hideBackButton?: boolean 59 59 isProfilePreview?: boolean 60 60 } ··· 69 69 70 70 // loading 71 71 // = 72 - if (!profile) { 72 + if (!profile || !moderation) { 73 73 return ( 74 74 <View style={pal.view}> 75 75 <LoadingPlaceholder width="100%" height={153} /> ··· 81 81 <View style={[styles.buttonsLine]}> 82 82 <LoadingPlaceholder width={167} height={31} style={styles.br50} /> 83 83 </View> 84 - <View> 85 - <Text type="title-2xl" style={[pal.text, styles.title]}> 86 - <Trans>Loading...</Trans> 87 - </Text> 88 - </View> 89 84 </View> 90 85 </View> 91 86 ) ··· 103 98 ) 104 99 } 105 100 101 + interface LoadedProps { 102 + profile: Shadow<AppBskyActorDefs.ProfileViewDetailed> 103 + moderation: ProfileModeration 104 + hideBackButton?: boolean 105 + isProfilePreview?: boolean 106 + } 107 + 106 108 function ProfileHeaderLoaded({ 107 109 profile, 108 110 moderation, 109 111 hideBackButton = false, 110 112 isProfilePreview, 111 - }: Props) { 113 + }: LoadedProps) { 112 114 const pal = usePalette('default') 113 115 const palInverted = usePalette('inverted') 114 116 const {currentAccount} = useSession()
+6 -10
src/view/screens/Profile.tsx
··· 1 1 import React, {useMemo} from 'react' 2 - import {ActivityIndicator, StyleSheet, View} from 'react-native' 2 + import {StyleSheet, View} from 'react-native' 3 3 import {useFocusEffect} from '@react-navigation/native' 4 4 import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api' 5 5 import {msg} from '@lingui/macro' ··· 73 73 if (isFetchingDid || isFetchingProfile || !moderationOpts) { 74 74 return ( 75 75 <CenteredView> 76 - <View style={s.p20}> 77 - <ActivityIndicator size="large" /> 78 - </View> 76 + <ProfileHeader 77 + profile={null} 78 + moderation={null} 79 + isProfilePreview={true} 80 + /> 79 81 </CenteredView> 80 82 ) 81 83 } ··· 157 159 showListsTab ? 'Lists' : undefined, 158 160 ].filter(Boolean) as string[] 159 161 }, [showLikesTab, showFeedsTab, showListsTab]) 160 - 161 - /* 162 - - todo 163 - - feeds 164 - - lists 165 - */ 166 162 167 163 useFocusEffect( 168 164 React.useCallback(() => {