π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Split
Manav Rathic18b1a7e830d
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex ba1b0af422..e37c2777f5 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -10,7 +10,7 @@ import { isDevBuild } from "ente-base/env";import { formattedDateRelative } from "ente-base/i18n-date";import log from "ente-base/log";import { downloadManager } from "ente-gallery/services/download";-import { EnteFile, enteFileDeletionDate } from "ente-media/file";+import { EnteFile } from "ente-media/file";import { fileDurationString } from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";import {@@ -26,6 +26,7 @@ import {} from "ente-new/photos/components/PlaceholderThumbnails";import { TileBottomTextOverlay } from "ente-new/photos/components/Tiles";import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";+import { enteFileDeletionDate } from "ente-new/photos/services/files";import { t } from "i18next";import memoize from "memoize-one";import { GalleryContext } from "pages/gallery";@@ -1283,6 +1284,9 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({)}{activeCollectionID == PseudoCollectionID.trash &&+ // TODO(RE):+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignorefile.isTrashed && (<TileBottomTextOverlay><Typography variant="small">diff --git a/web/packages/media/file.ts b/web/packages/media/file.tsindex d47ff88249..60335edd63 100644--- a/web/packages/media/file.ts+++ b/web/packages/media/file.ts@@ -3,7 +3,6 @@ import {decryptMetadataJSON,sharedCryptoWorker,} from "ente-base/crypto";-import { dateFromEpochMicroseconds } from "ente-base/date";import log from "ente-base/log";import { nullishToBlank, nullToUndefined } from "ente-utils/transform";import { z } from "zod/v4";@@ -312,16 +311,6 @@ export interface EnteFile* See: [Note: Metadatum]*/pubMagicMetadata?: MagicMetadataCore<FilePublicMagicMetadataData>;- /**- * `true` if this file is in trash (i.e. it has been deleted by the user,- * and will be permanently deleted after 30 days of being moved to trash).- */- isTrashed?: boolean;- /**- * If {@link isTrashed} is `true`, then {@link deleteBy} contains the epoch- * microseconds when this file will be permanently deleted.- */- deleteBy?: number;}/**@@ -745,16 +734,6 @@ export const mergeMetadata = (files: EnteFile[]) =>export const fileLogID = (file: EnteFile) =>`file ${fileFileName(file)} (${file.id})`;-/**- * Return the date when the file will be deleted permanently. Only valid for- * files that are in the user's trash.- *- * This is a convenience wrapper over the {@link deleteBy} property of a file,- * converting that epoch microsecond value into a JavaScript date.- */-export const enteFileDeletionDate = (file: EnteFile) =>- dateFromEpochMicroseconds(file.deleteBy);-export interface MagicMetadataCore<T> {version: number;count: number;diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex fd1f0cff05..fc6a397e69 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -31,6 +31,7 @@ import {groupFilesByCollectionID,sortFiles,uniqueFilesByID,+ type TrashedEnteFile,} from "../../services/files";import type { PeopleState, Person } from "../../services/ml/people";import type { SearchSuggestion } from "../../services/search/types";@@ -418,7 +419,7 @@ export type GalleryAction =collections: Collection[];normalFiles: EnteFile[];hiddenFiles: EnteFile[];- trashedFiles: EnteFile[];+ trashedFiles: TrashedEnteFile[];}| {type: "setCollections";diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.tsindex 293b9749cb..214d79d366 100644--- a/web/packages/new/photos/services/files.ts+++ b/web/packages/new/photos/services/files.ts@@ -1,4 +1,5 @@import { blobCache } from "ente-base/blob-cache";+import { dateFromEpochMicroseconds } from "ente-base/date";import log from "ente-base/log";import { apiURL } from "ente-base/origins";import type { Collection } from "ente-media/collection";@@ -230,7 +231,30 @@ export async function getLocalTrashedFiles() {return getTrashedFiles(await getLocalTrash());}-export function getTrashedFiles(trash: Trash): EnteFile[] {+export type TrashedEnteFile = EnteFile & {+ /**+ * `true` if this file is in trash (i.e. it has been deleted by the user,+ * and will be permanently deleted after 30 days of being moved to trash).+ */+ isTrashed?: boolean;+ /**+ * If {@link isTrashed} is `true`, then {@link deleteBy} contains the epoch+ * microseconds when this file will be permanently deleted.+ */+ deleteBy?: number;+};++/**+ * Return the date when the file will be deleted permanently. Only valid for+ * files that are in the user's trash.+ *+ * This is a convenience wrapper over the {@link deleteBy} property of a file,+ * converting that epoch microsecond value into a JavaScript date.+ */+export const enteFileDeletionDate = (file: TrashedEnteFile) =>+ dateFromEpochMicroseconds(file.deleteBy);++export function getTrashedFiles(trash: Trash): TrashedEnteFile[] {return sortTrashFiles(mergeMetadata(trash.map((trashedFile) => ({@@ -250,7 +274,7 @@ export function getTrashedFiles(trash: Trash): EnteFile[] {export const getLocalTrashFileIDs = () =>getLocalTrash().then((trash) => new Set(trash.map((f) => f.file.id)));-const sortTrashFiles = (files: EnteFile[]) => {+const sortTrashFiles = (files: TrashedEnteFile[]) => {return files.sort((a, b) => {if (a.deleteBy === b.deleteBy) {if (a.metadata.creationTime === b.metadata.creationTime) {