From 8a5e194af49f03728dab900cbbb4e1398e0c3a21 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 22 Jan 2022 11:01:46 +0530 Subject: [PATCH 1/6] fix file too large 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 d2a647d0d..a1a59aec1 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -547,7 +547,7 @@ const englishConstants = { INPROGRESS_UPLOADS: 'uploads in progress', TOO_LARGE_UPLOADS: 'large files', TOO_LARGE_INFO: - 'these files were not uploaded as they exceed the maximum size limit for your storage plan', + 'these files were not uploaded as they exceed our maximum file size limit', UPLOAD_TO_COLLECTION: 'upload to album', ARCHIVE: 'archive', ALL: 'all', From 3971e9c500125be3f1dbe63513be2fd3f133f849 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 22 Jan 2022 11:18:55 +0530 Subject: [PATCH 2/6] Revert "fix file too large description" This reverts commit 8a5e194af49f03728dab900cbbb4e1398e0c3a21. --- 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 a1a59aec1..d2a647d0d 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -547,7 +547,7 @@ const englishConstants = { INPROGRESS_UPLOADS: 'uploads in progress', TOO_LARGE_UPLOADS: 'large files', TOO_LARGE_INFO: - 'these files were not uploaded as they exceed our maximum file size limit', + 'these files were not uploaded as they exceed the maximum size limit for your storage plan', UPLOAD_TO_COLLECTION: 'upload to album', ARCHIVE: 'archive', ALL: 'all', From ae5bc333ef3f9e13bbb323330aa7054007958506 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 22 Jan 2022 12:26:41 +0530 Subject: [PATCH 3/6] add new category for files larger than available storage --- src/components/pages/gallery/UploadProgress.tsx | 10 ++++++++++ src/constants/upload/index.ts | 1 + src/services/upload/uploader.ts | 7 +++++-- src/utils/strings/englishConstants.tsx | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/pages/gallery/UploadProgress.tsx b/src/components/pages/gallery/UploadProgress.tsx index 38052ff16..b01c62c01 100644 --- a/src/components/pages/gallery/UploadProgress.tsx +++ b/src/components/pages/gallery/UploadProgress.tsx @@ -239,6 +239,16 @@ export default function UploadProgress(props: Props) { sectionTitle={constants.SKIPPED_FILES} sectionInfo={constants.SKIPPED_INFO} /> + Date: Sat, 22 Jan 2022 07:06:39 +0000 Subject: [PATCH 4/6] Bump nanoid from 3.1.25 to 3.2.0 Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.25 to 3.2.0. - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.1.25...3.2.0) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index fcb0daec0..a19a5143e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4592,9 +4592,9 @@ ms@2.1.2, ms@^2.1.1: integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== nanoid@^3.1.23: - version "3.1.25" - resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz" - integrity sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q== + version "3.2.0" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c" + integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA== native-url@0.3.4: version "0.3.4" From df9dd95f545cf20d530680e4e1a05f2d964be899 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 22 Jan 2022 13:26:54 +0530 Subject: [PATCH 5/6] update string --- src/utils/strings/englishConstants.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 2efca6872..3db2ce200 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -546,8 +546,7 @@ const englishConstants = { BLOCKED_UPLOADS: 'blocked uploads', INPROGRESS_UPLOADS: 'uploads in progress', TOO_LARGE_UPLOADS: 'large files', - LARGER_THAN_AVAILABLE_STORAGE_UPLOADS: - 'larger than available storage files', + LARGER_THAN_AVAILABLE_STORAGE_UPLOADS: 'insufficient storage', LARGER_THAN_AVAILABLE_STORAGE_INFO: 'these files were not uploaded as they exceed the maximum size limit for your storage plan', TOO_LARGE_INFO: From 07241efafd5f5a5648dcc9a925d2ce8a18eeb786 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 20 Jan 2022 12:13:10 +0530 Subject: [PATCH 6/6] change url casing --- sentry.client.config.js | 4 +-- src/components/PhotoFrame.tsx | 10 +++---- .../pages/gallery/CollectionSelector.tsx | 2 +- src/components/pages/gallery/PreviewCard.tsx | 6 ++-- src/pages/_app.tsx | 10 +++---- src/pages/credentials/index.tsx | 6 ++-- src/pages/gallery/index.tsx | 2 +- src/services/billingService.ts | 4 +-- src/services/downloadManager.ts | 30 +++++++++---------- src/services/upload/exifService.ts | 4 +-- src/utils/common/apiUtil.ts | 8 ++--- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/sentry.client.config.js b/sentry.client.config.js index 09e2fe20d..8d85c07d9 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -1,5 +1,5 @@ import * as Sentry from '@sentry/nextjs'; -import { getSentryTunnelUrl } from 'utils/common/apiUtil'; +import { getSentryTunnelURL } from 'utils/common/apiUtil'; import { getUserAnonymizedID } from 'utils/user'; import { getSentryDSN, @@ -21,7 +21,7 @@ Sentry.init({ release: SENTRY_RELEASE, attachStacktrace: true, autoSessionTracking: false, - tunnel: getSentryTunnelUrl(), + tunnel: getSentryTunnelURL(), // ... // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so diff --git a/src/components/PhotoFrame.tsx b/src/components/PhotoFrame.tsx index 2532c6aeb..712dd5810 100644 --- a/src/components/PhotoFrame.tsx +++ b/src/components/PhotoFrame.tsx @@ -209,7 +209,7 @@ const PhotoFrame = ({ }); }, [files, deleted, search, activeCollection]); - const updateUrl = (index: number) => (url: string) => { + const updateURL = (index: number) => (url: string) => { files[index] = { ...files[index], msrc: url, @@ -240,7 +240,7 @@ const PhotoFrame = ({ setFiles(files); }; - const updateSrcUrl = async (index: number, url: string) => { + const updateSrcURL = async (index: number, url: string) => { files[index] = { ...files[index], w: window.innerWidth, @@ -337,7 +337,7 @@ const PhotoFrame = ({ selected[file[index].id] ?? false }`} file={file[index]} - updateUrl={updateUrl(file[index].dataIndex)} + updateURL={updateURL(file[index].dataIndex)} onClick={onThumbnailClick(index)} selectable={!isSharedCollection} onSelect={handleSelect(file[index].id, index)} @@ -370,7 +370,7 @@ const PhotoFrame = ({ url = await DownloadManager.getThumbnail(item); galleryContext.thumbs.set(item.id, url); } - updateUrl(item.dataIndex)(url); + updateURL(item.dataIndex)(url); item.msrc = url; if (!item.src) { item.src = url; @@ -397,7 +397,7 @@ const PhotoFrame = ({ url = await DownloadManager.getFile(item, true); galleryContext.files.set(item.id, url); } - await updateSrcUrl(item.dataIndex, url); + await updateSrcURL(item.dataIndex, url); item.html = files[item.dataIndex].html; item.src = files[item.dataIndex].src; item.w = files[item.dataIndex].w; diff --git a/src/components/pages/gallery/CollectionSelector.tsx b/src/components/pages/gallery/CollectionSelector.tsx index ad39e3782..7a72a1266 100644 --- a/src/components/pages/gallery/CollectionSelector.tsx +++ b/src/components/pages/gallery/CollectionSelector.tsx @@ -82,7 +82,7 @@ function CollectionSelector({ {}} + updateURL={() => {}} onSelect={() => {}} forcedEnable /> diff --git a/src/components/pages/gallery/PreviewCard.tsx b/src/components/pages/gallery/PreviewCard.tsx index 54b09410e..8652d5e2e 100644 --- a/src/components/pages/gallery/PreviewCard.tsx +++ b/src/components/pages/gallery/PreviewCard.tsx @@ -9,7 +9,7 @@ import { GAP_BTW_TILES } from 'constants/gallery'; interface IProps { file: EnteFile; - updateUrl: (url: string) => void; + updateURL: (url: string) => void; onClick?: () => void; forcedEnable?: boolean; selectable?: boolean; @@ -161,7 +161,7 @@ export default function PreviewCard(props: IProps) { const { file, onClick, - updateUrl, + updateURL, forcedEnable, selectable, selected, @@ -185,7 +185,7 @@ export default function PreviewCard(props: IProps) { if (!file.src) { file.src = url; } - updateUrl(url); + updateURL(url); } } catch (e) { // no-op diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 5d170715b..42323cc61 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -479,8 +479,8 @@ type AppContextType = { sharedFiles: File[]; resetSharedFiles: () => void; setDisappearingFlashMessage: (message: FlashMessage) => void; - redirectUrl: string; - setRedirectUrl: (url: string) => void; + redirectURL: string; + setRedirectURL: (url: string) => void; }; export enum FLASH_MESSAGE_TYPE { @@ -510,7 +510,7 @@ export default function App({ Component, err }) { const [sharedFiles, setSharedFiles] = useState(null); const [redirectName, setRedirectName] = useState(null); const [flashMessage, setFlashMessage] = useState(null); - const [redirectUrl, setRedirectUrl] = useState(null); + const [redirectURL, setRedirectURL] = useState(null); useEffect(() => { if ( !('serviceWorker' in navigator) || @@ -644,8 +644,8 @@ export default function App({ Component, err }) { sharedFiles, resetSharedFiles, setDisappearingFlashMessage, - redirectUrl, - setRedirectUrl, + redirectURL, + setRedirectURL, }}> {loading ? ( diff --git a/src/pages/credentials/index.tsx b/src/pages/credentials/index.tsx index 86d44ce5f..2171b8b81 100644 --- a/src/pages/credentials/index.tsx +++ b/src/pages/credentials/index.tsx @@ -76,9 +76,9 @@ export default function Credentials() { } await SaveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key); await decryptAndStoreToken(key); - const redirectUrl = appContext.redirectUrl; - appContext.setRedirectUrl(null); - router.push(redirectUrl ?? PAGES.GALLERY); + const redirectURL = appContext.redirectURL; + appContext.setRedirectURL(null); + router.push(redirectURL ?? PAGES.GALLERY); } catch (e) { logError(e, 'user entered a wrong password'); setFieldError('passphrase', constants.INCORRECT_PASSPHRASE); diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 9a7d6136d..0a1bf7292 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -193,7 +193,7 @@ export default function Gallery() { useEffect(() => { const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); if (!key) { - appContext.setRedirectUrl(router.asPath); + appContext.setRedirectURL(router.asPath); router.push(PAGES.ROOT); return; } diff --git a/src/services/billingService.ts b/src/services/billingService.ts index cc6bf6021..f5fa048c7 100644 --- a/src/services/billingService.ts +++ b/src/services/billingService.ts @@ -1,4 +1,4 @@ -import { getEndpoint, getPaymentsUrl } from 'utils/common/apiUtil'; +import { getEndpoint, getPaymentsURL } from 'utils/common/apiUtil'; import { getToken } from 'utils/common/key'; import { setData, LS_KEYS } from 'utils/storage/localStorage'; import { convertToHumanReadable } from 'utils/billing'; @@ -154,7 +154,7 @@ class billingService { action: string ) { try { - window.location.href = `${getPaymentsUrl()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${ + window.location.href = `${getPaymentsURL()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${ window.location.origin }/gallery`; } catch (e) { diff --git a/src/services/downloadManager.ts b/src/services/downloadManager.ts index e49ca0ff7..afe0f65a2 100644 --- a/src/services/downloadManager.ts +++ b/src/services/downloadManager.ts @@ -1,5 +1,5 @@ import { getToken } from 'utils/common/key'; -import { getFileUrl, getThumbnailUrl } from 'utils/common/apiUtil'; +import { getFileURL, getThumbnailURL } from 'utils/common/apiUtil'; import CryptoWorker from 'utils/crypto'; import { generateStreamFromArrayBuffer, @@ -13,8 +13,8 @@ import { logError } from 'utils/sentry'; import { FILE_TYPE } from 'constants/file'; class DownloadManager { - private fileObjectUrlPromise = new Map>(); - private thumbnailObjectUrlPromise = new Map>(); + private fileObjectURLPromise = new Map>(); + private thumbnailObjectURLPromise = new Map>(); public async getThumbnail(file: EnteFile) { try { @@ -22,7 +22,7 @@ class DownloadManager { if (!token) { return null; } - if (!this.thumbnailObjectUrlPromise.get(file.id)) { + if (!this.thumbnailObjectURLPromise.get(file.id)) { const downloadPromise = async () => { const thumbnailCache = await caches.open('thumbs'); const cacheResp: Response = await thumbnailCache.match( @@ -43,12 +43,12 @@ class DownloadManager { } return URL.createObjectURL(thumbBlob); }; - this.thumbnailObjectUrlPromise.set(file.id, downloadPromise()); + this.thumbnailObjectURLPromise.set(file.id, downloadPromise()); } - return await this.thumbnailObjectUrlPromise.get(file.id); + return await this.thumbnailObjectURLPromise.get(file.id); } catch (e) { - this.thumbnailObjectUrlPromise.delete(file.id); + this.thumbnailObjectURLPromise.delete(file.id); logError(e, 'get preview Failed'); throw e; } @@ -56,7 +56,7 @@ class DownloadManager { downloadThumb = async (token: string, file: EnteFile) => { const resp = await HTTPService.get( - getThumbnailUrl(file.id), + getThumbnailURL(file.id), null, { 'X-Auth-Token': token }, { responseType: 'arraybuffer' } @@ -84,23 +84,23 @@ class DownloadManager { } return URL.createObjectURL(fileBlob); }; - if (!this.fileObjectUrlPromise.get(fileKey)) { - this.fileObjectUrlPromise.set( + if (!this.fileObjectURLPromise.get(fileKey)) { + this.fileObjectURLPromise.set( fileKey, getFilePromise(shouldBeConverted) ); } - const fileURL = await this.fileObjectUrlPromise.get(fileKey); + const fileURL = await this.fileObjectURLPromise.get(fileKey); return fileURL; } catch (e) { - this.fileObjectUrlPromise.delete(fileKey); + this.fileObjectURLPromise.delete(fileKey); logError(e, 'Failed to get File'); throw e; } }; public async getCachedOriginalFile(file: EnteFile) { - return await this.fileObjectUrlPromise.get(file.id.toString()); + return await this.fileObjectURLPromise.get(file.id.toString()); } async downloadFile(file: EnteFile) { @@ -114,7 +114,7 @@ class DownloadManager { file.metadata.fileType === FILE_TYPE.LIVE_PHOTO ) { const resp = await HTTPService.get( - getFileUrl(file.id), + getFileURL(file.id), null, { 'X-Auth-Token': token }, { responseType: 'arraybuffer' } @@ -126,7 +126,7 @@ class DownloadManager { ); return generateStreamFromArrayBuffer(decrypted); } - const resp = await fetch(getFileUrl(file.id), { + const resp = await fetch(getFileURL(file.id), { headers: { 'X-Auth-Token': token, }, diff --git a/src/services/upload/exifService.ts b/src/services/upload/exifService.ts index e463598ed..685994235 100644 --- a/src/services/upload/exifService.ts +++ b/src/services/upload/exifService.ts @@ -85,11 +85,11 @@ export async function updateFileCreationDateInEXIF( export async function convertImageToDataURL(reader: FileReader, url: string) { const blob = await fetch(url).then((r) => r.blob()); - const dataUrl = await new Promise((resolve) => { + const dataURL = await new Promise((resolve) => { reader.onload = () => resolve(reader.result as string); reader.readAsDataURL(blob); }); - return dataUrl; + return dataURL; } function dataURIToBlob(dataURI) { diff --git a/src/utils/common/apiUtil.ts b/src/utils/common/apiUtil.ts index 8288e6d30..fc59793c0 100644 --- a/src/utils/common/apiUtil.ts +++ b/src/utils/common/apiUtil.ts @@ -4,7 +4,7 @@ export const getEndpoint = () => { return endPoint; }; -export const getFileUrl = (id: number) => { +export const getFileURL = (id: number) => { if (process.env.NEXT_PUBLIC_ENTE_ENDPOINT !== undefined) { return ( `${process.env.NEXT_PUBLIC_ENTE_ENDPOINT}/files/download/${id}` ?? @@ -14,7 +14,7 @@ export const getFileUrl = (id: number) => { return `https://files.ente.io/?fileID=${id}`; }; -export const getThumbnailUrl = (id: number) => { +export const getThumbnailURL = (id: number) => { if (process.env.NEXT_PUBLIC_ENTE_ENDPOINT !== undefined) { return ( `${process.env.NEXT_PUBLIC_ENTE_ENDPOINT}/files/preview/${id}` ?? @@ -24,11 +24,11 @@ export const getThumbnailUrl = (id: number) => { return `https://thumbnails.ente.io/?fileID=${id}`; }; -export const getSentryTunnelUrl = () => { +export const getSentryTunnelURL = () => { return `https://sentry-reporter.ente.io`; }; -export const getPaymentsUrl = () => { +export const getPaymentsURL = () => { if (process.env.NEXT_PUBLIC_ENTE_ENDPOINT !== undefined) { return process.env.NEXT_PUBLIC_ENTE_PAYMENT_ENDPOINT; }