diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-13 17:30:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 17:30:56 -0800 |
commit | a81c4b68fa9ae87dea0b1dec76012ef7a69fca26 (patch) | |
tree | 95044e61cab77ab81bb107341ee2904f4170b622 /src/state/queries/profile.ts | |
parent | 0501c2be778b1a8517da6ea4111bcbd56dc056ed (diff) | |
download | voidsky-a81c4b68fa9ae87dea0b1dec76012ef7a69fca26.tar.zst |
Update Muted and Blocked accounts screens (react-query refactor) (#1892)
* Add my-blocked-accounts and my-muted-accounts queries * Update ProfileCard to use the profile shadow cache and useModerationOpts * Update blocked accounts and muted accounts screens
Diffstat (limited to 'src/state/queries/profile.ts')
-rw-r--r-- | src/state/queries/profile.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index 63367b261..de2b1d65c 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -11,6 +11,8 @@ import {useSession} from '../session' import {updateProfileShadow} from '../cache/profile-shadow' import {uploadBlob} from '#/lib/api' import {until} from '#/lib/async/until' +import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts' +import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts' export const RQKEY = (did: string) => ['profile', did] @@ -147,6 +149,7 @@ export function useProfileUnfollowMutation() { export function useProfileMuteMutation() { const {agent} = useSession() + const queryClient = useQueryClient() return useMutation<void, Error, {did: string}>({ mutationFn: async ({did}) => { await agent.mute(did) @@ -157,6 +160,9 @@ export function useProfileMuteMutation() { muted: true, }) }, + onSuccess() { + queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()}) + }, onError(error, variables) { // revert the optimistic update updateProfileShadow(variables.did, { @@ -189,6 +195,7 @@ export function useProfileUnmuteMutation() { export function useProfileBlockMutation() { const {agent, currentAccount} = useSession() + const queryClient = useQueryClient() return useMutation<{uri: string; cid: string}, Error, {did: string}>({ mutationFn: async ({did}) => { if (!currentAccount) { @@ -210,6 +217,7 @@ export function useProfileBlockMutation() { updateProfileShadow(variables.did, { blockingUri: data.uri, }) + queryClient.invalidateQueries({queryKey: RQKEY_MY_BLOCKED()}) }, onError(error, variables) { // revert the optimistic update |