Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Cache DID and profile basic on profile card presses (#3523)

* cache profiles

add onPress back

rm log

cache profile and did when pressing profile card

* minimal diff

authored by

Hailey and committed by
GitHub
3b9c5cee 7543f72b

+14 -2
+14 -2
src/view/com/profile/ProfileCard.tsx
··· 1 - import * as React from 'react' 1 + import React from 'react' 2 2 import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native' 3 3 import { 4 4 AppBskyActorDefs, ··· 7 7 ModerationDecision, 8 8 } from '@atproto/api' 9 9 import {Trans} from '@lingui/macro' 10 + import {useQueryClient} from '@tanstack/react-query' 10 11 11 12 import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription' 12 13 import {useProfileShadow} from '#/state/cache/profile-shadow' ··· 19 20 import {sanitizeDisplayName} from 'lib/strings/display-names' 20 21 import {sanitizeHandle} from 'lib/strings/handles' 21 22 import {s} from 'lib/styles' 23 + import {profileBasicQueryKey as RQKEY_PROFILE_BASIC} from 'state/queries/profile' 24 + import {RQKEY as RQKEY_URI} from 'state/queries/resolve-uri' 22 25 import {Link} from '../util/Link' 23 26 import {Text} from '../util/text/Text' 24 27 import {PreviewableUserAvatar} from '../util/UserAvatar' ··· 47 50 onPress?: () => void 48 51 style?: StyleProp<ViewStyle> 49 52 }) { 53 + const queryClient = useQueryClient() 50 54 const pal = usePalette('default') 51 55 const profile = useProfileShadow(profileUnshadowed) 52 56 const moderationOpts = useModerationOpts() 53 57 const isLabeler = profile?.associated?.labeler 58 + 59 + const onBeforePress = React.useCallback(() => { 60 + onPress?.() 61 + 62 + queryClient.setQueryData(RQKEY_URI(profile.handle), profile.did) 63 + queryClient.setQueryData(RQKEY_PROFILE_BASIC(profile.did), profile) 64 + }, [onPress, profile, queryClient]) 65 + 54 66 if (!moderationOpts) { 55 67 return null 56 68 } ··· 72 84 ]} 73 85 href={makeProfileLink(profile)} 74 86 title={profile.handle} 75 - onBeforePress={onPress} 76 87 asAnchor 88 + onBeforePress={onBeforePress} 77 89 anchorNoUnderline> 78 90 <View style={styles.layout}> 79 91 <View style={styles.layoutAvi}>