fix: Delete folder from cache after successful deletion (#3686)
* feat: Delete folder from cache after successful deletion * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
aaaf6f3784
commit
533d5afdc6
1 changed files with 8 additions and 1 deletions
|
|
@ -18,7 +18,8 @@ export const useDeleteFolders: useMutationFunctionType<
|
||||||
folder_id,
|
folder_id,
|
||||||
}: DeleteFoldersParams): Promise<any> => {
|
}: DeleteFoldersParams): Promise<any> => {
|
||||||
const res = await api.delete(`${getURL("FOLDERS")}/${folder_id}`);
|
const res = await api.delete(`${getURL("FOLDERS")}/${folder_id}`);
|
||||||
return res.data;
|
// returning id to use it in onSuccess and delete the folder from the cache
|
||||||
|
return folder_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutation: UseMutationResult<
|
const mutation: UseMutationResult<
|
||||||
|
|
@ -30,6 +31,12 @@ export const useDeleteFolders: useMutationFunctionType<
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.refetchQueries({ queryKey: ["useGetFolders"] });
|
queryClient.refetchQueries({ queryKey: ["useGetFolders"] });
|
||||||
},
|
},
|
||||||
|
onSuccess: (id) => {
|
||||||
|
queryClient.removeQueries({
|
||||||
|
queryKey: ["useGetFolder", { id }],
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return mutation;
|
return mutation;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue