Merge branch 'master' into remove-file-from-collection

This commit is contained in:
abhinav-grd 2021-09-28 14:03:39 +05:30
commit 2ef41995c8
2 changed files with 8 additions and 10 deletions

View file

@ -327,11 +327,10 @@ export default function Gallery() {
setCollectionSelectorView, setCollectionSelectorView,
selected, selected,
files, files,
clearSelection,
syncWithRemote,
setActiveCollection, setActiveCollection,
collection collection
); );
clearSelection();
} catch (e) { } catch (e) {
setDialogMessage({ setDialogMessage({
title: constants.ERROR, title: constants.ERROR,
@ -339,6 +338,9 @@ export default function Gallery() {
close: { variant: 'danger' }, close: { variant: 'danger' },
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally {
await syncWithRemote(false, true);
loadingBar.current.complete();
} }
}; };
@ -353,6 +355,7 @@ export default function Gallery() {
visibility visibility
); );
await updateMagicMetadata(updatedFiles); await updateMagicMetadata(updatedFiles);
clearSelection();
} catch (e) { } catch (e) {
switch (e.status?.toString()) { switch (e.status?.toString()) {
case ServerErrorCodes.FORBIDDEN: case ServerErrorCodes.FORBIDDEN:
@ -371,8 +374,7 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection(); await syncWithRemote(false, true);
syncWithRemote();
loadingBar.current.complete(); loadingBar.current.complete();
} }
}; };
@ -412,6 +414,7 @@ export default function Gallery() {
const fileIds = getSelectedFileIds(selected); const fileIds = getSelectedFileIds(selected);
await deleteFiles(fileIds); await deleteFiles(fileIds);
setDeleted([...deleted, ...fileIds]); setDeleted([...deleted, ...fileIds]);
clearSelection();
} catch (e) { } catch (e) {
switch (e.status?.toString()) { switch (e.status?.toString()) {
case ServerErrorCodes.FORBIDDEN: case ServerErrorCodes.FORBIDDEN:
@ -429,8 +432,7 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection(); await syncWithRemote(false, true);
syncWithRemote();
loadingBar.current.complete(); loadingBar.current.complete();
} }
}; };

View file

@ -21,8 +21,6 @@ export async function handleCollectionOps(
setCollectionSelectorView: (value: boolean) => void, setCollectionSelectorView: (value: boolean) => void,
selected: SelectedState, selected: SelectedState,
files: File[], files: File[],
clearSelection: () => void,
syncWithRemote: () => Promise<void>,
setActiveCollection: (id: number) => void, setActiveCollection: (id: number) => void,
collection: Collection collection: Collection
) { ) {
@ -45,8 +43,6 @@ export async function handleCollectionOps(
default: default:
throw Error(CustomError.INVALID_COLLECTION_OPERATION); throw Error(CustomError.INVALID_COLLECTION_OPERATION);
} }
clearSelection();
await syncWithRemote();
setActiveCollection(collection.id); setActiveCollection(collection.id);
} }