From 47f6b04520cd2beaab917fcb186b412cc67dc445 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:01:07 +0530 Subject: [PATCH] Remove unused code --- apps/cast/src/utils/collection/index.ts | 62 -------------------- apps/cast/src/utils/file/index.ts | 76 ------------------------- 2 files changed, 138 deletions(-) diff --git a/apps/cast/src/utils/collection/index.ts b/apps/cast/src/utils/collection/index.ts index 69d7cd7a6..6bdc4b10d 100644 --- a/apps/cast/src/utils/collection/index.ts +++ b/apps/cast/src/utils/collection/index.ts @@ -1,5 +1,4 @@ import { - createAlbum, getNonEmptyCollections, updateCollectionMagicMetadata, updatePublicCollectionMagicMetadata, @@ -22,7 +21,6 @@ import { SYSTEM_COLLECTION_TYPES, MOVE_TO_NOT_ALLOWED_COLLECTION, ADD_TO_NOT_ALLOWED_COLLECTION, - DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME, } from 'constants/collection'; import { getUnixTimeInMicroSecondsWithDelta } from 'utils/time'; import { SUB_TYPE, VISIBILITY_STATE } from 'types/magicMetadata'; @@ -32,14 +30,6 @@ import { t } from 'i18next'; import { getAlbumsURL } from '@ente/shared/network/api'; import { User } from '@ente/shared/user/types'; import { getData, LS_KEYS } from '@ente/shared/storage/localStorage'; -// import { SetCollectionDownloadProgressAttributes } from 'types/gallery'; -// import ElectronService from 'services/electron/common'; -// import { -// getCollectionExportPath, -// getUniqueCollectionExportName, -// } from 'utils/export'; -// import exportService from 'services/export'; -// import { CollectionDownloadProgressAttributes } from 'components/Collections/CollectionDownloadProgress'; export enum COLLECTION_OPS_TYPE { ADD, @@ -521,55 +511,3 @@ export function getNonHiddenCollections( export function getHiddenCollections(collections: Collection[]): Collection[] { return collections.filter((collection) => isHiddenCollection(collection)); } - -export async function splitNormalAndHiddenCollections( - collections: Collection[] -): Promise<{ - normalCollections: Collection[]; - hiddenCollections: Collection[]; -}> { - const normalCollections = []; - const hiddenCollections = []; - for (const collection of collections) { - if (isHiddenCollection(collection)) { - hiddenCollections.push(collection); - } else { - normalCollections.push(collection); - } - } - return { normalCollections, hiddenCollections }; -} - -export function constructCollectionNameMap( - collections: Collection[] -): Map { - return new Map( - (collections ?? []).map((collection) => [ - collection.id, - getCollectionUserFacingName(collection), - ]) - ); -} - -export const getCollectionUserFacingName = (collection: Collection) => { - if (isDefaultHiddenCollection(collection)) { - return DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME; - } - return collection.name; -}; - -export const getOrCreateAlbum = async ( - albumName: string, - existingCollections: Collection[] -) => { - const user: User = getData(LS_KEYS.USER); - if (!user?.id) { - throw Error('user missing'); - } - for (const collection of existingCollections) { - if (isValidReplacementAlbum(collection, user, albumName)) { - return collection; - } - } - return createAlbum(albumName); -}; diff --git a/apps/cast/src/utils/file/index.ts b/apps/cast/src/utils/file/index.ts index 63936e6c9..b0c171d44 100644 --- a/apps/cast/src/utils/file/index.ts +++ b/apps/cast/src/utils/file/index.ts @@ -6,7 +6,6 @@ import { FileMagicMetadata, FileMagicMetadataProps, FilePublicMagicMetadata, - FilePublicMagicMetadataProps, } from 'types/file'; import { decodeLivePhoto } from 'services/livePhotoService'; import { getFileType } from 'services/typeDetectionService'; @@ -34,7 +33,6 @@ import { deleteFromTrash, trashFiles, updateFileMagicMetadata, - updateFilePublicMagicMetadata, } from 'services/fileService'; import isElectron from 'is-electron'; // import imageProcessor from 'services/electron/imageProcessor'; @@ -533,72 +531,6 @@ export async function changeFilesVisibility( return await updateFileMagicMetadata(fileWithUpdatedMagicMetadataList); } -export async function changeFileCreationTime( - file: EnteFile, - editedTime: number -): Promise { - const updatedPublicMagicMetadataProps: FilePublicMagicMetadataProps = { - editedTime, - }; - const updatedPublicMagicMetadata: FilePublicMagicMetadata = - await updateMagicMetadata( - updatedPublicMagicMetadataProps, - file.pubMagicMetadata, - file.key - ); - const updateResult = await updateFilePublicMagicMetadata([ - { file, updatedPublicMagicMetadata }, - ]); - return updateResult[0]; -} - -export async function changeFileName( - file: EnteFile, - editedName: string -): Promise { - const updatedPublicMagicMetadataProps: FilePublicMagicMetadataProps = { - editedName, - }; - - const updatedPublicMagicMetadata: FilePublicMagicMetadata = - await updateMagicMetadata( - updatedPublicMagicMetadataProps, - file.pubMagicMetadata, - file.key - ); - const updateResult = await updateFilePublicMagicMetadata([ - { file, updatedPublicMagicMetadata }, - ]); - return updateResult[0]; -} - -export async function changeCaption( - file: EnteFile, - caption: string -): Promise { - const updatedPublicMagicMetadataProps: FilePublicMagicMetadataProps = { - caption, - }; - - const updatedPublicMagicMetadata: FilePublicMagicMetadata = - await updateMagicMetadata( - updatedPublicMagicMetadataProps, - file.pubMagicMetadata, - file.key - ); - const updateResult = await updateFilePublicMagicMetadata([ - { file, updatedPublicMagicMetadata }, - ]); - return updateResult[0]; -} - -export function isSharedFile(user: User, file: EnteFile) { - if (!user?.id || !file?.ownerID) { - return false; - } - return file.ownerID !== user.id; -} - export function mergeMetadata(files: EnteFile[]): EnteFile[] { return files.map((file) => { if (file.pubMagicMetadata?.data.editedTime) { @@ -612,14 +544,6 @@ export function mergeMetadata(files: EnteFile[]): EnteFile[] { }); } -export function updateExistingFilePubMetadata( - existingFile: EnteFile, - updatedFile: EnteFile -) { - existingFile.pubMagicMetadata = updatedFile.pubMagicMetadata; - existingFile.metadata = mergeMetadata([existingFile])[0].metadata; -} - export async function getFileFromURL(fileURL: string) { const fileBlob = await (await fetch(fileURL)).blob(); const fileFile = new File([fileBlob], 'temp');