diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index d74e7c42d..fee09340c 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -327,11 +327,10 @@ export default function Gallery() { setCollectionSelectorView, selected, files, - clearSelection, - syncWithRemote, setActiveCollection, collection ); + clearSelection(); } catch (e) { setDialogMessage({ title: constants.ERROR, @@ -339,6 +338,9 @@ export default function Gallery() { close: { variant: 'danger' }, content: constants.UNKNOWN_ERROR, }); + } finally { + await syncWithRemote(false, true); + loadingBar.current.complete(); } }; @@ -353,6 +355,7 @@ export default function Gallery() { visibility ); await updateMagicMetadata(updatedFiles); + clearSelection(); } catch (e) { switch (e.status?.toString()) { case ServerErrorCodes.FORBIDDEN: @@ -371,8 +374,7 @@ export default function Gallery() { content: constants.UNKNOWN_ERROR, }); } finally { - clearSelection(); - syncWithRemote(); + await syncWithRemote(false, true); loadingBar.current.complete(); } }; @@ -412,6 +414,7 @@ export default function Gallery() { const fileIds = getSelectedFileIds(selected); await deleteFiles(fileIds); setDeleted([...deleted, ...fileIds]); + clearSelection(); } catch (e) { switch (e.status?.toString()) { case ServerErrorCodes.FORBIDDEN: @@ -429,8 +432,7 @@ export default function Gallery() { content: constants.UNKNOWN_ERROR, }); } finally { - clearSelection(); - syncWithRemote(); + await syncWithRemote(false, true); loadingBar.current.complete(); } }; diff --git a/src/utils/collection/index.ts b/src/utils/collection/index.ts index 4a1497b06..8701632d9 100644 --- a/src/utils/collection/index.ts +++ b/src/utils/collection/index.ts @@ -21,8 +21,6 @@ export async function handleCollectionOps( setCollectionSelectorView: (value: boolean) => void, selected: SelectedState, files: File[], - clearSelection: () => void, - syncWithRemote: () => Promise, setActiveCollection: (id: number) => void, collection: Collection ) { @@ -45,8 +43,6 @@ export async function handleCollectionOps( default: throw Error(CustomError.INVALID_COLLECTION_OPERATION); } - clearSelection(); - await syncWithRemote(); setActiveCollection(collection.id); }