Remove unused code
This commit is contained in:
parent
d2c088b9ef
commit
47f6b04520
2 changed files with 0 additions and 138 deletions
|
@ -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<number, string> {
|
||||
return new Map<number, string>(
|
||||
(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);
|
||||
};
|
||||
|
|
|
@ -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<EnteFile> {
|
||||
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<EnteFile> {
|
||||
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<EnteFile> {
|
||||
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');
|
||||
|
|
Loading…
Add table
Reference in a new issue