move state update before call

This commit is contained in:
Abhinav 2023-02-04 16:53:56 +05:30
parent 4aafc80b65
commit 3cbfe58ec0

View file

@ -384,9 +384,9 @@ function PhotoViewer(props: Iprops) {
const { deletedFileIds, setDeletedFileIds, items: oldItems } = props;
try {
deletedFileIds.add(file.id);
await trashFiles([file]);
setDeletedFileIds(new Set(deletedFileIds));
updateItems(props.items.filter((item) => item.id !== file.id));
await trashFiles([file]);
needUpdate.current = true;
} catch (e) {
logError(e, 'trashFile failed');