Skip to content

Commit

Permalink
fix: Delete folder from cache after successful deletion (#3686)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
anovazzi1 and autofix-ci[bot] committed Sep 4, 2024
1 parent aaaf6f3 commit 533d5af
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -30,6 +31,12 @@ export const useDeleteFolders: useMutationFunctionType<
onSettled: () => {
queryClient.refetchQueries({ queryKey: ["useGetFolders"] });
},
onSuccess: (id) => {
queryClient.removeQueries({
queryKey: ["useGetFolder", { id }],
exact: true,
});
},
});

return mutation;
Expand Down

0 comments on commit 533d5af

Please # to comment.