diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index b034550cd..f487783f3 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -287,13 +287,35 @@ export default function Gallery() { callback: (collectionName) => addToCollectionHelper(collectionName, null), }); - const deleteFileHelper = () => { + const deleteFileHelper = async () => { loadingBar.current?.continuousStart(); - deleteFiles( - getSelectedFileIds(selected), - clearSelection, - syncWithRemote, - ); + try { + await deleteFiles( + getSelectedFileIds(selected), + clearSelection, + syncWithRemote, + + ); + } catch (e) { + loadingBar.current.complete(); + switch (e.status?.toString()) { + case errorCodes.ERR_FORBIDDEN: + setDialogMessage({ + title: constants.ERROR, + staticBackdrop: true, + close: { variant: 'danger' }, + content: constants.NOT_FILE_OWNER, + }); + loadingBar.current.complete(); + return; + } + setDialogMessage({ + title: constants.ERROR, + staticBackdrop: true, + close: { variant: 'danger' }, + content: constants.UNKNOWN_ERROR, + }); + } }; const updateSearch = (search: Search) => { diff --git a/src/services/fileService.ts b/src/services/fileService.ts index af49a1039..64e92e673 100644 --- a/src/services/fileService.ts +++ b/src/services/fileService.ts @@ -190,5 +190,6 @@ export const deleteFiles = async ( syncWithRemote(); } catch (e) { console.error('delete failed'); + throw e; } }; diff --git a/src/utils/common/errorUtil.ts b/src/utils/common/errorUtil.ts index 018394948..5dddc07be 100644 --- a/src/utils/common/errorUtil.ts +++ b/src/utils/common/errorUtil.ts @@ -6,6 +6,7 @@ export const errorCodes = { ERR_NO_INTERNET_CONNECTION: '1', ERR_SESSION_EXPIRED: '401', ERR_KEY_MISSING: '2', + ERR_FORBIDDEN: '403', }; const AXIOS_NETWORK_ERROR = 'Network Error'; diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 192697eba..90e53527d 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -352,6 +352,7 @@ const englishConstants = { seconds ) ), + NOT_FILE_OWNER: 'deleting shared collection files is not allowed', }; export default englishConstants;