diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index b4cc05874..287a00b72 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -326,12 +326,12 @@ export default function Gallery() { setCollectionSelectorView, selected, files, - clearSelection, - syncWithRemote, + setActiveCollection, collectionName, collection ); + clearSelection(); } catch (e) { setDialogMessage({ title: constants.ERROR, @@ -339,6 +339,9 @@ export default function Gallery() { close: { variant: 'danger' }, content: constants.UNKNOWN_ERROR, }); + } finally { + await syncWithRemote(false, true); + loadingBar.current.complete(); } }; @@ -353,12 +356,12 @@ export default function Gallery() { setCollectionSelectorView, selected, files, - clearSelection, - syncWithRemote, + setActiveCollection, collectionName, collection ); + clearSelection(); } catch (e) { setDialogMessage({ title: constants.ERROR, @@ -366,6 +369,9 @@ export default function Gallery() { close: { variant: 'danger' }, content: constants.UNKNOWN_ERROR, }); + } finally { + await syncWithRemote(false, true); + loadingBar.current.complete(); } }; const changeFilesVisibilityHelper = async ( @@ -379,6 +385,7 @@ export default function Gallery() { visibility ); await updateMagicMetadata(updatedFiles); + clearSelection(); } catch (e) { switch (e.status?.toString()) { case ServerErrorCodes.FORBIDDEN: @@ -397,8 +404,7 @@ export default function Gallery() { content: constants.UNKNOWN_ERROR, }); } finally { - clearSelection(); - syncWithRemote(); + await syncWithRemote(false, true); loadingBar.current.complete(); } }; @@ -445,6 +451,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: @@ -462,8 +469,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 1c13c40c1..2683236a5 100644 --- a/src/utils/collection/index.ts +++ b/src/utils/collection/index.ts @@ -21,8 +21,6 @@ export async function copyOrMoveFromCollection( setCollectionSelectorView: (value: boolean) => void, selected: SelectedState, files: File[], - clearSelection: () => void, - syncWithRemote: () => Promise, setActiveCollection: (id: number) => void, collectionName: string, existingCollection: Collection @@ -52,8 +50,6 @@ export async function copyOrMoveFromCollection( default: throw Error(CustomError.INVALID_COLLECTION_OPERATION); } - clearSelection(); - await syncWithRemote(); setActiveCollection(collection.id); }