clear selection only on successful completion of operation

This commit is contained in:
abhinav-grd 2021-09-28 10:29:43 +05:30
parent e0d153e048
commit 5bd6ba0788

View file

@ -331,6 +331,7 @@ export default function Gallery() {
collectionName, collectionName,
collection collection
); );
clearSelection();
} catch (e) { } catch (e) {
setDialogMessage({ setDialogMessage({
title: constants.ERROR, title: constants.ERROR,
@ -339,7 +340,6 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection();
await syncWithRemote(false, true); await syncWithRemote(false, true);
loadingBar.current.complete(); loadingBar.current.complete();
} }
@ -361,6 +361,7 @@ export default function Gallery() {
collectionName, collectionName,
collection collection
); );
clearSelection();
} catch (e) { } catch (e) {
setDialogMessage({ setDialogMessage({
title: constants.ERROR, title: constants.ERROR,
@ -369,7 +370,6 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection();
await syncWithRemote(false, true); await syncWithRemote(false, true);
loadingBar.current.complete(); loadingBar.current.complete();
} }
@ -385,6 +385,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:
@ -403,7 +404,6 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection();
await syncWithRemote(false, true); await syncWithRemote(false, true);
loadingBar.current.complete(); loadingBar.current.complete();
} }
@ -451,6 +451,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:
@ -468,7 +469,6 @@ export default function Gallery() {
content: constants.UNKNOWN_ERROR, content: constants.UNKNOWN_ERROR,
}); });
} finally { } finally {
clearSelection();
await syncWithRemote(false, true); await syncWithRemote(false, true);
loadingBar.current.complete(); loadingBar.current.complete();
} }