Skip to content

Commit

Permalink
Added more asynchronous calls to further streamline process
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff McMillen authored and Jeff McMillen committed Nov 26, 2024
1 parent 9286b7e commit a8b4899
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions client/src/hooks/datafiles/mutations/useTrash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function useTrash() {
});
};

const { mutate } = useMutation({ mutationFn: trashUtil });
const { mutateAsync } = useMutation({ mutationFn: trashUtil });

const trash = ({
selection,
Expand All @@ -61,17 +61,16 @@ function useTrash() {
const filteredSelected = selected.filter(
(f: any) => status[f.id] !== 'SUCCESS'
);
dispatch({
type: 'DATA_FILES_SET_OPERATION_STATUS_BY_KEY',
payload: {
status: 'RUNNING',
key: (index: string) => index,
operation: 'trash',
},
});

filteredSelected.forEach(() => {
mutate(
const trashCalls: Promise<any>[] = filteredSelected.forEach((file: any) => {
dispatch({
type: 'DATA_FILES_SET_OPERATION_STATUS_BY_KEY',
payload: {
status: 'RUNNING',
key: (index: string) => index,
operation: 'trash',
},
});
return mutateAsync(
{
api: api,
scheme: scheme,
Expand All @@ -89,13 +88,13 @@ function useTrash() {
operation: 'trash',
},
});
callback(response.name, response.path);
dispatch({
type: 'ADD_TOAST',
payload: {
message: `${selection} moved to Trash`,
},
});
callback(response.name, response.path);
},
onError: () => {
dispatch({
Expand All @@ -110,6 +109,8 @@ function useTrash() {
}
);
});
// filteredSelected.forEach(() => {
// });
};

return { trash, status, setStatus };
Expand Down

0 comments on commit a8b4899

Please sign in to comment.