mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

Hide normal mute if muted by list, and invalidate profile query upon list mute (#2048)

* Hide normal mute if muted by list, and invalidate profile query upon list mute

* Prevent profile flashing

authored by

Eric Bailey and committed by
GitHub
47b0d36b 46b63acc

+33 -19
+30 -16
src/view/com/profile/ProfileHeader.tsx
··· 7 7 } from 'react-native' 8 8 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 9 9 import {useNavigation} from '@react-navigation/native' 10 + import {useQueryClient} from '@tanstack/react-query' 10 11 import { 11 12 AppBskyActorDefs, 12 13 ProfileModeration, ··· 32 33 import {useModalControls} from '#/state/modals' 33 34 import {useLightboxControls, ProfileImageLightbox} from '#/state/lightbox' 34 35 import { 36 + RQKEY as profileQueryKey, 35 37 useProfileMuteMutationQueue, 36 38 useProfileBlockMutationQueue, 37 39 useProfileFollowMutationQueue, ··· 134 136 const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(profile) 135 137 const [queueMute, queueUnmute] = useProfileMuteMutationQueue(profile) 136 138 const [queueBlock, queueUnblock] = useProfileBlockMutationQueue(profile) 139 + const queryClient = useQueryClient() 140 + 141 + const invalidateProfileQuery = React.useCallback(() => { 142 + queryClient.invalidateQueries({ 143 + queryKey: profileQueryKey(profile.did), 144 + }) 145 + }, [queryClient, profile.did]) 137 146 138 147 const onPressBack = React.useCallback(() => { 139 148 if (navigation.canGoBack()) { ··· 209 218 name: 'user-add-remove-lists', 210 219 subject: profile.did, 211 220 displayName: profile.displayName || profile.handle, 221 + onAdd: invalidateProfileQuery, 222 + onRemove: invalidateProfileQuery, 212 223 }) 213 - }, [track, profile, openModal]) 224 + }, [track, profile, openModal, invalidateProfileQuery]) 214 225 215 226 const onPressMuteAccount = React.useCallback(async () => { 216 227 track('ProfileHeader:MuteAccountButtonClicked') ··· 325 336 }) 326 337 if (!isMe) { 327 338 if (!profile.viewer?.blocking) { 328 - items.push({ 329 - testID: 'profileHeaderDropdownMuteBtn', 330 - label: profile.viewer?.muted 331 - ? _(msg`Unmute Account`) 332 - : _(msg`Mute Account`), 333 - onPress: profile.viewer?.muted 334 - ? onPressUnmuteAccount 335 - : onPressMuteAccount, 336 - icon: { 337 - ios: { 338 - name: 'speaker.slash', 339 + if (!profile.viewer?.mutedByList) { 340 + items.push({ 341 + testID: 'profileHeaderDropdownMuteBtn', 342 + label: profile.viewer?.muted 343 + ? _(msg`Unmute Account`) 344 + : _(msg`Mute Account`), 345 + onPress: profile.viewer?.muted 346 + ? onPressUnmuteAccount 347 + : onPressMuteAccount, 348 + icon: { 349 + ios: { 350 + name: 'speaker.slash', 351 + }, 352 + android: 'ic_lock_silent_mode', 353 + web: 'comment-slash', 339 354 }, 340 - android: 'ic_lock_silent_mode', 341 - web: 'comment-slash', 342 - }, 343 - }) 355 + }) 356 + } 344 357 } 345 358 if (!profile.viewer?.blockingByList) { 346 359 items.push({ ··· 379 392 isMe, 380 393 hasSession, 381 394 profile.viewer?.muted, 395 + profile.viewer?.mutedByList, 382 396 profile.viewer?.blocking, 383 397 profile.viewer?.blockingByList, 384 398 onPressShare,
+3 -3
src/view/screens/Profile.tsx
··· 50 50 data: resolvedDid, 51 51 error: resolveError, 52 52 refetch: refetchDid, 53 - isFetching: isFetchingDid, 53 + isInitialLoading: isInitialLoadingDid, 54 54 } = useResolveDidQuery(name) 55 55 const { 56 56 data: profile, 57 57 error: profileError, 58 58 refetch: refetchProfile, 59 - isFetching: isFetchingProfile, 59 + isInitialLoading: isInitialLoadingProfile, 60 60 } = useProfileQuery({ 61 61 did: resolvedDid, 62 62 }) ··· 69 69 } 70 70 }, [resolveError, refetchDid, refetchProfile]) 71 71 72 - if (isFetchingDid || isFetchingProfile || !moderationOpts) { 72 + if (isInitialLoadingDid || isInitialLoadingProfile || !moderationOpts) { 73 73 return ( 74 74 <CenteredView> 75 75 <ProfileHeader