add timeout on mutation delete document
This commit is contained in:
parent
3e10f97659
commit
ae2e95e023
1 changed files with 5 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ interface DeleteDocumentResponse {
|
|||
}
|
||||
|
||||
const deleteDocument = async (
|
||||
data: DeleteDocumentRequest
|
||||
data: DeleteDocumentRequest,
|
||||
): Promise<DeleteDocumentResponse> => {
|
||||
const response = await fetch("/api/documents/delete-by-filename", {
|
||||
method: "POST",
|
||||
|
|
@ -37,9 +37,11 @@ export const useDeleteDocument = () => {
|
|||
|
||||
return useMutation({
|
||||
mutationFn: deleteDocument,
|
||||
onSuccess: () => {
|
||||
onSettled: () => {
|
||||
// Invalidate and refetch search queries to update the UI
|
||||
queryClient.invalidateQueries({ queryKey: ["search"] });
|
||||
setTimeout(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["search"] });
|
||||
}, 1000);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue