|
@@ -17,7 +17,6 @@ import {
|
|
FileMagicMetadata,
|
|
FileMagicMetadata,
|
|
FilePublicMagicMetadata,
|
|
FilePublicMagicMetadata,
|
|
} from "types/file";
|
|
} from "types/file";
|
|
-import { SelectedState } from "types/gallery";
|
|
|
|
import { isArchivedFile } from "utils/magicMetadata";
|
|
import { isArchivedFile } from "utils/magicMetadata";
|
|
|
|
|
|
import { CustomError } from "@ente/shared/error";
|
|
import { CustomError } from "@ente/shared/error";
|
|
@@ -32,44 +31,6 @@ import { isPlaybackPossible } from "utils/photoFrame";
|
|
|
|
|
|
const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
|
|
const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
|
|
|
|
|
|
-export enum FILE_OPS_TYPE {
|
|
|
|
- DOWNLOAD,
|
|
|
|
- FIX_TIME,
|
|
|
|
- ARCHIVE,
|
|
|
|
- UNARCHIVE,
|
|
|
|
- HIDE,
|
|
|
|
- TRASH,
|
|
|
|
- DELETE_PERMANENTLY,
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-export function groupFilesBasedOnCollectionID(files: EnteFile[]) {
|
|
|
|
- const collectionWiseFiles = new Map<number, EnteFile[]>();
|
|
|
|
- for (const file of files) {
|
|
|
|
- if (!collectionWiseFiles.has(file.collectionID)) {
|
|
|
|
- collectionWiseFiles.set(file.collectionID, []);
|
|
|
|
- }
|
|
|
|
- collectionWiseFiles.get(file.collectionID).push(file);
|
|
|
|
- }
|
|
|
|
- return collectionWiseFiles;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function getSelectedFileIds(selectedFiles: SelectedState) {
|
|
|
|
- const filesIDs: number[] = [];
|
|
|
|
- for (const [key, val] of Object.entries(selectedFiles)) {
|
|
|
|
- if (typeof val === "boolean" && val) {
|
|
|
|
- filesIDs.push(Number(key));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return new Set(filesIDs);
|
|
|
|
-}
|
|
|
|
-export function getSelectedFiles(
|
|
|
|
- selected: SelectedState,
|
|
|
|
- files: EnteFile[],
|
|
|
|
-): EnteFile[] {
|
|
|
|
- const selectedFilesIDs = getSelectedFileIds(selected);
|
|
|
|
- return files.filter((file) => selectedFilesIDs.has(file.id));
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
export function sortFiles(files: EnteFile[], sortAsc = false) {
|
|
export function sortFiles(files: EnteFile[], sortAsc = false) {
|
|
// sort based on the time of creation time of the file,
|
|
// sort based on the time of creation time of the file,
|
|
// for files with same creation time, sort based on the time of last modification
|
|
// for files with same creation time, sort based on the time of last modification
|