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,
|
||||
}: DeleteFoldersParams): Promise<any> => {
|
||||
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<
|
||||
|
|
@ -30,6 +31,12 @@ export const useDeleteFolders: useMutationFunctionType<
|
|||
onSettled: () => {
|
||||
queryClient.refetchQueries({ queryKey: ["useGetFolders"] });
|
||||
},
|
||||
onSuccess: (id) => {
|
||||
queryClient.removeQueries({
|
||||
queryKey: ["useGetFolder", { id }],
|
||||
exact: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return mutation;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue