nicolium: restore the code
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -6,6 +6,7 @@ import type { CreateAccountParams, Relationship } from 'pl-api';
|
||||
|
||||
const ACCOUNT_BLOCK_SUCCESS = 'ACCOUNT_BLOCK_SUCCESS' as const;
|
||||
const ACCOUNT_MUTE_SUCCESS = 'ACCOUNT_MUTE_SUCCESS' as const;
|
||||
const ACCOUNT_UNFOLLOW_SUCCESS = 'ACCOUNT_UNFOLLOW_SUCCESS' as const;
|
||||
|
||||
const createAccount =
|
||||
(params: CreateAccountParams) => (_dispatch: AppDispatch, getState: () => RootState) =>
|
||||
@ -14,9 +15,18 @@ const createAccount =
|
||||
.then((response) => ({ params, response }));
|
||||
|
||||
type AccountsAction = {
|
||||
type: typeof ACCOUNT_BLOCK_SUCCESS | typeof ACCOUNT_MUTE_SUCCESS;
|
||||
type:
|
||||
| typeof ACCOUNT_BLOCK_SUCCESS
|
||||
| typeof ACCOUNT_MUTE_SUCCESS
|
||||
| typeof ACCOUNT_UNFOLLOW_SUCCESS;
|
||||
relationship: Relationship;
|
||||
statuses: Record<string, NormalizedStatus>;
|
||||
};
|
||||
|
||||
export { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS, createAccount, type AccountsAction };
|
||||
export {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
ACCOUNT_UNFOLLOW_SUCCESS,
|
||||
createAccount,
|
||||
type AccountsAction,
|
||||
};
|
||||
|
||||
@ -4,6 +4,7 @@ import { useMemo } from 'react';
|
||||
import {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
ACCOUNT_UNFOLLOW_SUCCESS,
|
||||
type AccountsAction,
|
||||
} from '@/actions/accounts';
|
||||
import { batcher } from '@/api/batcher';
|
||||
@ -121,6 +122,7 @@ const useFollowAccountMutation = (accountId: string) => {
|
||||
|
||||
const useUnfollowAccountMutation = (accountId: string) => {
|
||||
const client = useClient();
|
||||
const dispatch = useAppDispatch();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
@ -142,6 +144,14 @@ const useUnfollowAccountMutation = (accountId: string) => {
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(queryKeys.accountRelationships.show(accountId), data);
|
||||
|
||||
dispatch((dispatch, getState) => {
|
||||
return dispatch({
|
||||
type: ACCOUNT_UNFOLLOW_SUCCESS,
|
||||
relationship: data,
|
||||
statuses: getState().statuses,
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user