nicolium: restore the code

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-02-27 18:10:31 +01:00
parent 4b65b9b931
commit b3665d6966
2 changed files with 22 additions and 2 deletions

View File

@ -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,
};

View File

@ -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,
});
});
},
});
};