Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client

Cache profile view before opening AfterReportDialog (#9962)

authored by samuel.fm and committed by

GitHub 37a82761 612a7783

+33 -6
+2 -2
src/components/dms/AfterReportDialog.tsx
··· 69 69 const control = Dialog.useDialogContext() 70 70 const { 71 71 data: profile, 72 - isLoading, 72 + isPending, 73 73 isError, 74 74 } = useProfileQuery({ 75 75 did: params.message.sender.did, 76 76 }) 77 77 78 - return isLoading ? ( 78 + return isPending ? ( 79 79 <View style={[a.w_full, a.py_5xl, a.align_center]}> 80 80 <Loader size="lg" /> 81 81 </View>
+12 -1
src/components/dms/ConvoMenu.tsx
··· 5 5 import {useLingui} from '@lingui/react' 6 6 import {Trans} from '@lingui/react/macro' 7 7 import {useNavigation} from '@react-navigation/native' 8 + import {useQueryClient} from '@tanstack/react-query' 8 9 9 10 import {type NavigationProp} from '#/lib/routes/types' 10 11 import {type Shadow} from '#/state/cache/types' ··· 13 14 useMarkAsReadMutation, 14 15 } from '#/state/queries/messages/conversation' 15 16 import {useMuteConvo} from '#/state/queries/messages/mute-conversation' 16 - import {useProfileBlockMutationQueue} from '#/state/queries/profile' 17 + import { 18 + unstableCacheProfileView, 19 + useProfileBlockMutationQueue, 20 + } from '#/state/queries/profile' 17 21 import * as Toast from '#/view/com/util/Toast' 18 22 import {type ViewStyleProp} from '#/alf' 19 23 import {atoms as a} from '#/alf' ··· 63 67 style?: ViewStyleProp['style'] 64 68 }): React.ReactNode => { 65 69 const {_} = useLingui() 70 + const queryClient = useQueryClient() 66 71 67 72 const leaveConvoControl = Prompt.usePromptControl() 68 73 const reportControl = Prompt.usePromptControl() ··· 125 130 }} 126 131 control={reportControl} 127 132 onAfterSubmit={() => { 133 + const sender = convo.members.find( 134 + member => member.did === latestReportableMessage.sender.did, 135 + ) 136 + if (sender) { 137 + unstableCacheProfileView(queryClient, sender) 138 + } 128 139 blockOrDeleteControl.open() 129 140 }} 130 141 />
+6 -1
src/components/dms/MessageContextMenu.tsx
··· 4 4 import {type ChatBskyConvoDefs, RichText} from '@atproto/api' 5 5 import {msg} from '@lingui/core/macro' 6 6 import {useLingui} from '@lingui/react' 7 + import {useQueryClient} from '@tanstack/react-query' 7 8 8 9 import {useTranslate} from '#/lib/hooks/useTranslate' 9 10 import {richTextToString} from '#/lib/strings/rich-text-helpers' 10 11 import {useConvoActive} from '#/state/messages/convo' 11 12 import {useLanguagePrefs} from '#/state/preferences' 13 + import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache' 12 14 import {useSession} from '#/state/session' 13 15 import * as Toast from '#/view/com/util/Toast' 14 16 import * as ContextMenu from '#/components/ContextMenu' ··· 36 38 const {_} = useLingui() 37 39 const ax = useAnalytics() 38 40 const {currentAccount} = useSession() 41 + const queryClient = useQueryClient() 39 42 const convo = useConvoActive() 40 43 const deleteControl = usePromptControl() 41 44 const reportControl = usePromptControl() ··· 170 173 </ContextMenu.Root> 171 174 172 175 <ReportDialog 173 - // currentScreen="conversation" 174 176 control={reportControl} 175 177 subject={{ 176 178 view: 'message', ··· 178 180 message, 179 181 }} 180 182 onAfterSubmit={() => { 183 + if (sender) { 184 + unstableCacheProfileView(queryClient, sender) 185 + } 181 186 blockOrDeleteControl.open() 182 187 }} 183 188 />
+1 -1
src/components/moderation/ReportDialog/action.ts
··· 102 102 } 103 103 104 104 if (__DEV__) { 105 - logger.info('Submitting report', { 105 + logger.info('Submitting report (dry run)', { 106 106 labeler: { 107 107 handle: labeler.creator.handle, 108 108 },
+12 -1
src/screens/Messages/components/RequestButtons.tsx
··· 12 12 import {useAcceptConversation} from '#/state/queries/messages/accept-conversation' 13 13 import {precacheConvoQuery} from '#/state/queries/messages/conversation' 14 14 import {useLeaveConvo} from '#/state/queries/messages/leave-conversation' 15 - import {useProfileBlockMutationQueue} from '#/state/queries/profile' 15 + import { 16 + unstableCacheProfileView, 17 + useProfileBlockMutationQueue, 18 + } from '#/state/queries/profile' 16 19 import * as Toast from '#/view/com/util/Toast' 17 20 import {atoms as a} from '#/alf' 18 21 import { ··· 53 56 const {_} = useLingui() 54 57 const shadowedProfile = useProfileShadow(profile) 55 58 const navigation = useNavigation<NavigationProp>() 59 + const queryClient = useQueryClient() 60 + 56 61 const {mutate: leaveConvo} = useLeaveConvo(convo.id, { 57 62 onMutate: () => { 58 63 if (currentScreen === 'conversation') { ··· 174 179 }} 175 180 control={reportControl} 176 181 onAfterSubmit={() => { 182 + const sender = convo.members.find( 183 + member => member.did === lastMessage.sender.did, 184 + ) 185 + if (sender) { 186 + unstableCacheProfileView(queryClient, sender) 187 + } 177 188 blockOrDeleteControl.open() 178 189 }} 179 190 />