From 16cc4844f114cf847c01b8e408b2750b095b742c Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 30 Jan 2022 13:36:50 +0530 Subject: [PATCH 01/12] don't send validTill and deviceLimit and use default options --- src/services/collectionService.ts | 10 +--------- src/types/collection/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index 2b4cdbb43..83c83fe17 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -23,12 +23,7 @@ import { CreatePublicAccessTokenRequest, PublicURL, } from 'types/collection'; -import { - COLLECTION_SORT_BY, - CollectionType, - COLLECTION_SHARE_DEFAULT_DEVICE_LIMIT, - COLLECTION_SHARE_DEFAULT_VALID_DURATION, -} from 'constants/collection'; +import { COLLECTION_SORT_BY, CollectionType } from 'constants/collection'; const ENDPOINT = getEndpoint(); const COLLECTION_TABLE = 'collections'; @@ -588,9 +583,6 @@ export const createShareableURL = async (collection: Collection) => { } const createPublicAccessTokenRequest: CreatePublicAccessTokenRequest = { collectionID: collection.id, - validTill: - Date.now() * 1000 + COLLECTION_SHARE_DEFAULT_VALID_DURATION, - deviceLimit: COLLECTION_SHARE_DEFAULT_DEVICE_LIMIT, }; const resp = await HTTPService.post( `${ENDPOINT}/collections/share-url`, diff --git a/src/types/collection/index.ts b/src/types/collection/index.ts index 0becd3778..83dffdda5 100644 --- a/src/types/collection/index.ts +++ b/src/types/collection/index.ts @@ -28,8 +28,8 @@ export interface PublicURL { export interface CreatePublicAccessTokenRequest { collectionID: number; - validTill: number; - deviceLimit: number; + validTill?: number; + deviceLimit?: number; } export interface EncryptedFileKey { From 033a6020e24c7a8cdc7679b91a2affd2df989180 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 30 Jan 2022 13:37:32 +0530 Subject: [PATCH 02/12] handle too TOO_MANY_REQUEST error --- src/services/publicCollectionService.ts | 3 ++- src/utils/error/index.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/publicCollectionService.ts b/src/services/publicCollectionService.ts index 33164c7bc..f316bac9b 100644 --- a/src/services/publicCollectionService.ts +++ b/src/services/publicCollectionService.ts @@ -269,7 +269,8 @@ export const getPublicCollection = async ( const errorCode = error.status.toString(); if ( errorCode === ServerErrorCodes.SESSION_EXPIRED || - errorCode === ServerErrorCodes.TOKEN_EXPIRED + errorCode === ServerErrorCodes.TOKEN_EXPIRED || + errorCode === ServerErrorCodes.TOO_MANY_REQUEST ) { throw Error(CustomError.TOKEN_EXPIRED); } diff --git a/src/utils/error/index.ts b/src/utils/error/index.ts index 163a9fac1..dd17fc885 100644 --- a/src/utils/error/index.ts +++ b/src/utils/error/index.ts @@ -8,6 +8,7 @@ export const ServerErrorCodes = { STORAGE_LIMIT_EXCEEDED: '426', FILE_TOO_LARGE: '413', TOKEN_EXPIRED: '410', + TOO_MANY_REQUEST: '429', }; export enum CustomError { From a750e7e900165d00f193901fb9b780ef7fb9f01d Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 30 Jan 2022 16:03:13 +0530 Subject: [PATCH 03/12] update sharing Error handling --- src/pages/shared-albums/index.tsx | 5 +- src/services/publicCollectionService.ts | 18 ++---- src/utils/error/index.ts | 75 ++++++++++++++++--------- 3 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index f8cc6b335..3d27e73e8 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -19,7 +19,7 @@ import { defaultPublicCollectionGalleryContext, PublicCollectionGalleryContext, } from 'utils/publicCollectionGallery'; -import { CustomError } from 'utils/error'; +import { CustomError, parseSharingErrorCodes } from 'utils/error'; import Container from 'components/Container'; import constants from 'utils/strings/constants'; import EnteSpinner from 'components/EnteSpinner'; @@ -116,7 +116,8 @@ export default function PublicCollectionGallery() { await syncPublicFiles(token.current, collection, setPublicFiles); } catch (e) { - if (e.message === CustomError.TOKEN_EXPIRED) { + const parsedError = parseSharingErrorCodes(e); + if (parsedError.message === CustomError.TOKEN_EXPIRED) { // share has been disabled // local cache should be cleared removePublicCollectionWithFiles(collectionKey.current); diff --git a/src/services/publicCollectionService.ts b/src/services/publicCollectionService.ts index f316bac9b..129af88dd 100644 --- a/src/services/publicCollectionService.ts +++ b/src/services/publicCollectionService.ts @@ -12,7 +12,6 @@ import { } from 'types/publicCollection'; import CryptoWorker from 'utils/crypto'; import { REPORT_REASON } from 'constants/publicCollection'; -import { CustomError, ServerErrorCodes } from 'utils/error'; const ENDPOINT = getEndpoint(); const PUBLIC_COLLECTION_FILES_TABLE = 'public-collection-files'; @@ -175,7 +174,7 @@ export const syncPublicFiles = async ( return [...sortFiles(mergeMetadata(files))]; } catch (e) { logError(e, 'failed to get local or sync shared collection files'); - return []; + throw e; } }; @@ -260,21 +259,12 @@ export const getPublicCollection = async ( }; await savePublicCollection(collection); return collection; - } catch (error) { - logError(error, 'failed to get public collection', { + } catch (e) { + logError(e, 'failed to get public collection', { collectionKey, token, }); - if ('status' in error) { - const errorCode = error.status.toString(); - if ( - errorCode === ServerErrorCodes.SESSION_EXPIRED || - errorCode === ServerErrorCodes.TOKEN_EXPIRED || - errorCode === ServerErrorCodes.TOO_MANY_REQUEST - ) { - throw Error(CustomError.TOKEN_EXPIRED); - } - } + throw e; } }; diff --git a/src/utils/error/index.ts b/src/utils/error/index.ts index dd17fc885..45d3e2f52 100644 --- a/src/utils/error/index.ts +++ b/src/utils/error/index.ts @@ -1,4 +1,3 @@ -import { AxiosResponse } from 'axios'; import constants from 'utils/strings/constants'; export const ServerErrorCodes = { @@ -9,6 +8,9 @@ export const ServerErrorCodes = { FILE_TOO_LARGE: '413', TOKEN_EXPIRED: '410', TOO_MANY_REQUEST: '429', + BAD_REQUEST: '400', + PAYMENT_REQUIRED: '402', + NOT_FOUND: '404', }; export enum CustomError { @@ -32,9 +34,12 @@ export enum CustomError { WAIT_TIME_EXCEEDED = 'thumbnail generation wait time exceeded', REQUEST_CANCELLED = 'request canceled', TOKEN_EXPIRED = 'token expired', + BAD_REQUEST = 'bad request', + SUBSCRIPTION_NEEDED = 'subscription not present', + NOT_FOUND = 'not found ', } -function parseUploadError(error: AxiosResponse) { +function parseUploadErrorCodes(error) { let parsedMessage = null; if (error?.status) { const errorCode = error.status.toString(); @@ -54,19 +59,15 @@ function parseUploadError(error: AxiosResponse) { default: parsedMessage = `${constants.UNKNOWN_ERROR} statusCode:${errorCode}`; } + } else { + parsedMessage = error.message; } - return { - parsedError: new Error(parsedMessage), - }; + return new Error(parsedMessage); } -export function handleUploadError(error: AxiosResponse | Error): Error { - let parsedError: Error = null; - if ('status' in error) { - parsedError = parseUploadError(error).parsedError; - } else { - parsedError = error; - } +export function handleUploadError(error): Error { + const parsedError = parseUploadErrorCodes(error); + // breaking errors switch (parsedError.message) { case CustomError.SUBSCRIPTION_EXPIRED: @@ -101,25 +102,49 @@ export function errorWithContext(originalError: Error, context: string) { originalError.stack; return errorWithContext; } - -export const handleSharingErrors = (e) => { - let errorMessage = null; - if ('status' in e) { - switch (e?.status) { - case 400: - errorMessage = constants.SHARING_BAD_REQUEST_ERROR; +export const parseSharingErrorCodes = (error) => { + let parsedMessage = null; + if (error?.status) { + const errorCode = error.status.toString(); + switch (errorCode) { + case ServerErrorCodes.BAD_REQUEST: + parsedMessage = CustomError.BAD_REQUEST; break; - case 402: - errorMessage = constants.SHARING_DISABLED_FOR_FREE_ACCOUNTS; + case ServerErrorCodes.PAYMENT_REQUIRED: + parsedMessage = CustomError.SUBSCRIPTION_NEEDED; break; - case 404: - errorMessage = constants.USER_DOES_NOT_EXIST; + case ServerErrorCodes.NOT_FOUND: + parsedMessage = CustomError.NOT_FOUND; + break; + case ServerErrorCodes.SESSION_EXPIRED: + case ServerErrorCodes.TOKEN_EXPIRED: + case ServerErrorCodes.TOO_MANY_REQUEST: + parsedMessage = CustomError.TOKEN_EXPIRED; break; default: - errorMessage = `${constants.UNKNOWN_ERROR} statusCode:${e.status}`; + parsedMessage = `${constants.UNKNOWN_ERROR} statusCode:${errorCode}`; } } else { - errorMessage = e.message; + parsedMessage = error.message; + } + return new Error(parsedMessage); +}; + +export const handleSharingErrors = (error) => { + const parsedError = parseSharingErrorCodes(error); + let errorMessage = ''; + switch (parsedError.message) { + case CustomError.BAD_REQUEST: + errorMessage = constants.SHARING_BAD_REQUEST_ERROR; + break; + case CustomError.SUBSCRIPTION_NEEDED: + errorMessage = constants.SHARING_DISABLED_FOR_FREE_ACCOUNTS; + break; + case CustomError.NOT_FOUND: + errorMessage = constants.USER_DOES_NOT_EXIST; + break; + default: + errorMessage = parsedError.message; } return errorMessage; }; From 21799ba06ee7bf4d88340934324a11d82dcd4e1d Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 30 Jan 2022 16:56:07 +0530 Subject: [PATCH 04/12] setLoading(false) after local files loaded --- src/pages/shared-albums/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index 3d27e73e8..5ddf7b191 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -58,7 +58,6 @@ export default function PublicCollectionGallery() { useEffect(() => { appContext.showNavBar(true); - setLoading(false); const currentURL = new URL(window.location.href); if (currentURL.pathname !== PAGES.ROOT) { router.push( @@ -99,6 +98,7 @@ export default function PublicCollectionGallery() { setPublicFiles(localPublicFiles); } syncWithRemote(); + setLoading(false); }; main(); }, []); From 4b2ca8e98c2a5ba1d0b72b5d8abc19400e838108 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 12:34:22 +0530 Subject: [PATCH 05/12] improve loaders --- src/pages/shared-albums/index.tsx | 76 +++++++++++++++++-------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index 5ddf7b191..838009281 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -28,6 +28,13 @@ import CryptoWorker from 'utils/crypto'; import { PAGES } from 'constants/pages'; import router from 'next/router'; +const Loader = () => ( + + + Loading... + + +); export default function PublicCollectionGallery() { const token = useRef(null); const collectionKey = useRef(null); @@ -58,6 +65,7 @@ export default function PublicCollectionGallery() { useEffect(() => { appContext.showNavBar(true); + startLoading(); const currentURL = new URL(window.location.href); if (currentURL.pathname !== PAGES.ROOT) { router.push( @@ -74,31 +82,35 @@ export default function PublicCollectionGallery() { ); } const main = async () => { - const worker = await new CryptoWorker(); - url.current = window.location.href; - const currentURL = new URL(url.current); - const t = currentURL.searchParams.get('t'); - const ck = currentURL.hash.slice(1); - const dck = await worker.fromHex(ck); - if (!t || !dck) { - setLoading(false); - return; - } - token.current = t; - collectionKey.current = dck; - url.current = window.location.href; - const localCollection = await getLocalPublicCollection( - collectionKey.current - ); - if (localCollection) { - setPublicCollection(localCollection); - const localPublicFiles = sortFiles( - mergeMetadata(await getLocalPublicFiles(localCollection)) + try { + const worker = await new CryptoWorker(); + url.current = window.location.href; + const currentURL = new URL(url.current); + const t = currentURL.searchParams.get('t'); + const ck = currentURL.hash.slice(1); + const dck = await worker.fromHex(ck); + if (!t || !dck) { + return; + } + token.current = t; + collectionKey.current = dck; + url.current = window.location.href; + const localCollection = await getLocalPublicCollection( + collectionKey.current ); - setPublicFiles(localPublicFiles); + if (localCollection) { + setPublicCollection(localCollection); + const localPublicFiles = sortFiles( + mergeMetadata( + await getLocalPublicFiles(localCollection) + ) + ); + setPublicFiles(localPublicFiles); + } + syncWithRemote(); + } finally { + setLoading(false); } - syncWithRemote(); - setLoading(false); }; main(); }, []); @@ -128,18 +140,14 @@ export default function PublicCollectionGallery() { finishLoading(); } }; - if (loading) { - return ( - - - Loading... - - - ); - } - if (!isLoadingBarRunning && !publicFiles) { - return {constants.NOT_FOUND}; + if (loading || !publicFiles?.length) { + if (!isLoadingBarRunning) { + return {constants.NOT_FOUND}; + } else { + return ; + } } + return ( Date: Mon, 31 Jan 2022 14:00:26 +0530 Subject: [PATCH 06/12] use accessToken and collectionID combined as collectionUID --- src/pages/shared-albums/index.tsx | 15 +++++--- src/services/publicCollectionService.ts | 47 ++++++++++++------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index 838009281..45ada49f2 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -5,6 +5,7 @@ import { getLocalPublicCollection, getLocalPublicFiles, getPublicCollection, + getPublicCollectionUID, removePublicCollectionWithFiles, syncPublicFiles, } from 'services/publicCollectionService'; @@ -100,10 +101,13 @@ export default function PublicCollectionGallery() { ); if (localCollection) { setPublicCollection(localCollection); + const collectionUID = getPublicCollectionUID( + collectionKey.current, + token.current + ); + const localFiles = await getLocalPublicFiles(collectionUID); const localPublicFiles = sortFiles( - mergeMetadata( - await getLocalPublicFiles(localCollection) - ) + mergeMetadata(localFiles) ); setPublicFiles(localPublicFiles); } @@ -132,7 +136,10 @@ export default function PublicCollectionGallery() { if (parsedError.message === CustomError.TOKEN_EXPIRED) { // share has been disabled // local cache should be cleared - removePublicCollectionWithFiles(collectionKey.current); + removePublicCollectionWithFiles( + token.current, + collectionKey.current + ); setPublicCollection(null); setPublicFiles([]); } diff --git a/src/services/publicCollectionService.ts b/src/services/publicCollectionService.ts index 129af88dd..faf14b349 100644 --- a/src/services/publicCollectionService.ts +++ b/src/services/publicCollectionService.ts @@ -17,11 +17,13 @@ const ENDPOINT = getEndpoint(); const PUBLIC_COLLECTION_FILES_TABLE = 'public-collection-files'; const PUBLIC_COLLECTIONS_TABLE = 'public-collections'; -const getCollectionUID = (collection: Collection) => `${collection.key}`; -const getCollectionSyncTimeUID = (collectionUID: string) => +export const getPublicCollectionUID = (collectionKey: string, token: string) => + `${collectionKey.slice(0, 8)}-${token.slice(0, 8)}`; + +const getPublicCollectionSyncTimeUID = (collectionUID: string) => `public-${collectionUID}-time`; -export const getLocalPublicFiles = async (collection: Collection) => { +export const getLocalPublicFiles = async (collectionUID: string) => { const localSavedPublicCollectionFiles = ( (await localForage.getItem( @@ -29,8 +31,7 @@ export const getLocalPublicFiles = async (collection: Collection) => { )) || [] ).find( (localSavedPublicCollectionFiles) => - localSavedPublicCollectionFiles.collectionUID === - getCollectionUID(collection) + localSavedPublicCollectionFiles.collectionUID === collectionUID ) || ({ collectionUID: null, @@ -105,13 +106,17 @@ const dedupeCollectionFiles = ( const getPublicCollectionLastSyncTime = async (collectionUID: string) => (await localForage.getItem( - getCollectionSyncTimeUID(collectionUID) + getPublicCollectionSyncTimeUID(collectionUID) )) ?? 0; const setPublicCollectionLastSyncTime = async ( collectionUID: string, time: number -) => await localForage.setItem(getCollectionSyncTimeUID(collectionUID), time); +) => + await localForage.setItem( + getPublicCollectionSyncTimeUID(collectionUID), + time + ); export const syncPublicFiles = async ( token: string, @@ -120,14 +125,15 @@ export const syncPublicFiles = async ( ) => { try { let files: EnteFile[] = []; - const localFiles = await getLocalPublicFiles(collection); + const collectionUID = getPublicCollectionUID(collection.key, token); + const localFiles = await getLocalPublicFiles(collectionUID); files.push(...localFiles); try { if (!token) { return files; } const lastSyncTime = await getPublicCollectionLastSyncTime( - getCollectionUID(collection) + collectionUID ); if (collection.updationTime === lastSyncTime) { return files; @@ -159,12 +165,9 @@ export const syncPublicFiles = async ( } files.push(file); } - await savePublicCollectionFiles( - getCollectionUID(collection), - files - ); + await savePublicCollectionFiles(collectionUID, files); await setPublicCollectionLastSyncTime( - getCollectionUID(collection), + collectionUID, collection.updationTime ); setPublicFiles([...sortFiles(mergeMetadata(files))]); @@ -308,21 +311,17 @@ export const reportAbuse = async ( }; export const removePublicCollectionWithFiles = async ( + token: string, collectionKey: string ) => { + const collectionUID = getPublicCollectionUID(collectionKey, token); const publicCollections = - (await localForage.getItem(PUBLIC_COLLECTIONS_TABLE)) ?? + (await localForage.getItem(PUBLIC_COLLECTIONS_TABLE)) || []; - const collectionToRemove = publicCollections.find( - (collection) => (collection.key = collectionKey) - ); - if (!collectionToRemove) { - return; - } await localForage.setItem( PUBLIC_COLLECTIONS_TABLE, publicCollections.filter( - (collection) => collection.id !== collectionToRemove.id + (collection) => collection.key !== collectionKey ) ); @@ -333,9 +332,7 @@ export const removePublicCollectionWithFiles = async ( await localForage.setItem( PUBLIC_COLLECTION_FILES_TABLE, publicCollectionFiles.filter( - (collectionFiles) => - collectionFiles.collectionUID === - getCollectionUID(collectionToRemove) + (collectionFiles) => collectionFiles.collectionUID !== collectionUID ) ); }; From 7d5a03598d2032186cf69432f8b06e91e7adfe2a Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 16:10:34 +0530 Subject: [PATCH 07/12] add isLoadingBarRunning before calling complete --- src/pages/gallery/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 7fc0b3552..18a3d2594 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -348,7 +348,7 @@ export default function Gallery() { isLoadingBarRunning.current = true; }; const finishLoading = () => { - loadingBar.current?.complete(); + isLoadingBarRunning.current && loadingBar.current?.complete(); isLoadingBarRunning.current = false; }; From b8b6c20302e1f21b54697e954ed5e7a00cc34f62 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 16:18:27 +0530 Subject: [PATCH 08/12] improve loading --- src/pages/shared-albums/index.tsx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index 45ada49f2..2d9bff6f1 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -50,23 +50,22 @@ export default function PublicCollectionGallery() { const openReportForm = () => setAbuseReportFormView(true); const closeReportForm = () => setAbuseReportFormView(false); const loadingBar = useRef(null); - const [isLoadingBarRunning, setIsLoadingBarRunning] = useState(false); + const isLoadingBarRunning = useRef(false); const openMessageDialog = () => setMessageDialogView(true); const closeMessageDialog = () => setMessageDialogView(false); - const startLoading = () => { - !isLoadingBarRunning && loadingBar.current?.continuousStart(); - setIsLoadingBarRunning(true); + const startLoadingBar = () => { + !isLoadingBarRunning.current && loadingBar.current?.continuousStart(); + isLoadingBarRunning.current = true; }; - const finishLoading = () => { - loadingBar.current?.complete(); - setIsLoadingBarRunning(false); + const finishLoadingBar = () => { + isLoadingBarRunning.current && loadingBar.current?.complete(); + isLoadingBarRunning.current = false; }; useEffect(() => { appContext.showNavBar(true); - startLoading(); const currentURL = new URL(window.location.href); if (currentURL.pathname !== PAGES.ROOT) { router.push( @@ -111,7 +110,7 @@ export default function PublicCollectionGallery() { ); setPublicFiles(localPublicFiles); } - syncWithRemote(); + await syncWithRemote(); } finally { setLoading(false); } @@ -123,7 +122,7 @@ export default function PublicCollectionGallery() { const syncWithRemote = async () => { try { - startLoading(); + startLoadingBar(); const collection = await getPublicCollection( token.current, collectionKey.current @@ -144,14 +143,15 @@ export default function PublicCollectionGallery() { setPublicFiles([]); } } finally { - finishLoading(); + finishLoadingBar(); } }; - if (loading || !publicFiles?.length) { - if (!isLoadingBarRunning) { - return {constants.NOT_FOUND}; - } else { + + if (!publicFiles?.length) { + if (loading) { return ; + } else { + return {constants.NOT_FOUND}; } } From 262eb0884f63aad9e309cc87582f1a068d2c81a3 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 16:40:31 +0530 Subject: [PATCH 09/12] show loader till files null and loading --- src/pages/shared-albums/index.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/shared-albums/index.tsx b/src/pages/shared-albums/index.tsx index 2d9bff6f1..11bf8f730 100644 --- a/src/pages/shared-albums/index.tsx +++ b/src/pages/shared-albums/index.tsx @@ -40,7 +40,7 @@ export default function PublicCollectionGallery() { const token = useRef(null); const collectionKey = useRef(null); const url = useRef(null); - const [publicFiles, setPublicFiles] = useState([]); + const [publicFiles, setPublicFiles] = useState(null); const [publicCollection, setPublicCollection] = useState(null); const appContext = useContext(AppContext); const [abuseReportFormView, setAbuseReportFormView] = useState(false); @@ -147,12 +147,11 @@ export default function PublicCollectionGallery() { } }; - if (!publicFiles?.length) { - if (loading) { - return ; - } else { - return {constants.NOT_FOUND}; - } + if (!publicFiles && loading) { + return ; + } + if (!publicFiles?.length && !loading) { + return {constants.NOT_FOUND}; } return ( From 2cc30ebe8849188a725f7d70db6a9f79c232a78e Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 23:31:41 +0530 Subject: [PATCH 10/12] update abuse report success strings --- src/components/pages/sharedAlbum/AbuseReportForm.tsx | 2 +- src/utils/strings/englishConstants.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/pages/sharedAlbum/AbuseReportForm.tsx b/src/components/pages/sharedAlbum/AbuseReportForm.tsx index e06008512..262b588a7 100644 --- a/src/components/pages/sharedAlbum/AbuseReportForm.tsx +++ b/src/components/pages/sharedAlbum/AbuseReportForm.tsx @@ -86,7 +86,7 @@ export function AbuseReportForm({ show, close, url }: Iprops) { publicCollectionGalleryContent.setDialogMessage({ title: constants.REPORT_SUBMIT_SUCCESS_TITLE, content: constants.REPORT_SUBMIT_SUCCESS_CONTENT, - close: { text: constants.CLOSE }, + close: { text: constants.OK }, }); } catch (e) { setFieldError('signature', constants.REPORT_SUBMIT_FAILED); diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 559d93c67..acff3519d 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -612,7 +612,7 @@ const englishConstants = { 'fill out the following form to submit the abuse report. Refer the dmca section for more detail for privacy policy of submitting a report ', OTHER_REASON_REQUIRES_COMMENTS: 'reason = other, require a mandatory comment ', - REPORT_SUBMIT_SUCCESS_CONTENT: 'thank you, your report have been submitted', + REPORT_SUBMIT_SUCCESS_CONTENT: 'your report have been submitted', REPORT_SUBMIT_SUCCESS_TITLE: 'report sent', REPORT_SUBMIT_FAILED: 'failed to sent report, try again', INSTALL: 'install', From 2266d7a115daa741a6b3d111f2205d339baf323b Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 23:32:47 +0530 Subject: [PATCH 11/12] update abuse report description --- src/utils/strings/englishConstants.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index acff3519d..65cc82616 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -609,7 +609,7 @@ const englishConstants = { OPEN_PLAN_SELECTOR_MODAL_FAILED: 'failed to open plans', COMMENT: 'comment', ABUSE_REPORT_DESCRIPTION: - 'fill out the following form to submit the abuse report. Refer the dmca section for more detail for privacy policy of submitting a report ', + 'Note: Submitting this report will notify the album owner.', OTHER_REASON_REQUIRES_COMMENTS: 'reason = other, require a mandatory comment ', REPORT_SUBMIT_SUCCESS_CONTENT: 'your report have been submitted', From f335a9bbfdd7f0f5d85b8a175c717d0557e94050 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 31 Jan 2022 23:36:53 +0530 Subject: [PATCH 12/12] fix grammer --- src/utils/strings/englishConstants.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 65cc82616..494be4f30 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -612,7 +612,7 @@ const englishConstants = { 'Note: Submitting this report will notify the album owner.', OTHER_REASON_REQUIRES_COMMENTS: 'reason = other, require a mandatory comment ', - REPORT_SUBMIT_SUCCESS_CONTENT: 'your report have been submitted', + REPORT_SUBMIT_SUCCESS_CONTENT: 'your report has been submitted', REPORT_SUBMIT_SUCCESS_TITLE: 'report sent', REPORT_SUBMIT_FAILED: 'failed to sent report, try again', INSTALL: 'install',