Parcourir la source

change url casing

Abhinav il y a 3 ans
Parent
commit
07241efafd

+ 2 - 2
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

+ 5 - 5
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;

+ 1 - 1
src/components/pages/gallery/CollectionSelector.tsx

@@ -82,7 +82,7 @@ function CollectionSelector({
             <CollectionCard>
                 <PreviewCard
                     file={item.file}
-                    updateUrl={() => {}}
+                    updateURL={() => {}}
                     onSelect={() => {}}
                     forcedEnable
                 />

+ 3 - 3
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

+ 5 - 5
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<File[]>(null);
     const [redirectName, setRedirectName] = useState<string>(null);
     const [flashMessage, setFlashMessage] = useState<FlashMessage>(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 ? (
                     <Container>

+ 3 - 3
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);

+ 1 - 1
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;
         }

+ 2 - 2
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) {

+ 15 - 15
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<string, Promise<string>>();
-    private thumbnailObjectUrlPromise = new Map<number, Promise<string>>();
+    private fileObjectURLPromise = new Map<string, Promise<string>>();
+    private thumbnailObjectURLPromise = new Map<number, Promise<string>>();
 
     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,
             },

+ 2 - 2
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<string>((resolve) => {
+    const dataURL = await new Promise<string>((resolve) => {
         reader.onload = () => resolve(reader.result as string);
         reader.readAsDataURL(blob);
     });
-    return dataUrl;
+    return dataURL;
 }
 
 function dataURIToBlob(dataURI) {

+ 4 - 4
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;
     }