Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update UserInfoText component (#1927)

authored by

Paul Frazee and committed by
GitHub
8a1fd160 a84b2f9f

+4 -29
+4 -29
src/view/com/util/UserInfoText.tsx
··· 1 - import React, {useState, useEffect} from 'react' 1 + import React from 'react' 2 2 import {AppBskyActorGetProfile as GetProfile} from '@atproto/api' 3 3 import {StyleProp, StyleSheet, TextStyle} from 'react-native' 4 4 import {TextLinkOnWebOnly} from './Link' 5 5 import {Text} from './text/Text' 6 6 import {LoadingPlaceholder} from './LoadingPlaceholder' 7 - import {useStores} from 'state/index' 8 7 import {TypographyVariant} from 'lib/ThemeContext' 9 8 import {sanitizeDisplayName} from 'lib/strings/display-names' 10 9 import {sanitizeHandle} from 'lib/strings/handles' 11 10 import {makeProfileLink} from 'lib/routes/links' 11 + import {useProfileQuery} from '#/state/queries/profile' 12 12 13 13 export function UserInfoText({ 14 14 type = 'md', ··· 29 29 attr = attr || 'handle' 30 30 failed = failed || 'user' 31 31 32 - const store = useStores() 33 - const [profile, setProfile] = useState<undefined | GetProfile.OutputSchema>( 34 - undefined, 35 - ) 36 - const [didFail, setFailed] = useState<boolean>(false) 37 - 38 - useEffect(() => { 39 - let aborted = false 40 - store.profiles.getProfile(did).then( 41 - v => { 42 - if (aborted) { 43 - return 44 - } 45 - setProfile(v.data) 46 - }, 47 - _err => { 48 - if (aborted) { 49 - return 50 - } 51 - setFailed(true) 52 - }, 53 - ) 54 - return () => { 55 - aborted = true 56 - } 57 - }, [did, store.profiles]) 32 + const {data: profile, isError} = useProfileQuery({did}) 58 33 59 34 let inner 60 - if (didFail) { 35 + if (isError) { 61 36 inner = ( 62 37 <Text type={type} style={style} numberOfLines={1}> 63 38 {failed}