Merge pull request #163 from ente-io/handle-failure

Handle failure
This commit is contained in:
Abhinav-grd 2021-09-28 13:56:11 +05:30 committed by GitHub
commit efb61ab53f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View file

@ -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();
}
};

View file

@ -21,8 +21,6 @@ export async function copyOrMoveFromCollection(
setCollectionSelectorView: (value: boolean) => void,
selected: SelectedState,
files: File[],
clearSelection: () => void,
syncWithRemote: () => Promise<void>,
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);
}