Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Delete folder from cache after successful deletion #3686

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ export const useDeleteFolders: useMutationFunctionType<
onSettled: () => {
queryClient.refetchQueries({ queryKey: ["useGetFolders"] });
},
onSuccess: (id) => {
queryClient.removeQueries({ queryKey: ["useGetFolder",{ id }],exact: true });
},
});

return mutation;
Expand Down
Loading