Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cleanup

Manav Rathic23cd8d2f012
diff --git a/web/packages/media/file.ts b/web/packages/media/file.ts
index 11938fc429..4ad4947b04 100644
--- a/web/packages/media/file.ts
+++ b/web/packages/media/file.ts
@@ -484,11 +484,6 @@ export const FileDiffResponse = z.object({
hasMore: z.boolean(),
});
-export interface FileWithUpdatedPublicMagicMetadata {
- file: EnteFile;
- updatedPublicMagicMetadata: FilePublicMagicMetadata;
-}
-
export type FileMagicMetadata = MagicMetadataCore<FilePrivateMagicMetadataData>;
export type FilePrivateMagicMetadata =
MagicMetadataCore<FilePrivateMagicMetadataData>;
@@ -496,58 +491,6 @@ export type FilePrivateMagicMetadata =
export type FilePublicMagicMetadata =
MagicMetadataCore<FilePublicMagicMetadataData>;
-export interface TrashItem extends Omit<EncryptedTrashItem, "file"> {
- file: EnteFile;
-}
-
-export interface EncryptedTrashItem {
- file: EncryptedEnteFile;
- /**
- * `true` if the file no longer in trash because it was permanently deleted.
- *
- * This field is relevant when we obtain a trash item as part of the trash
- * diff. It indicates that the file which was previously in trash is no
- * longer in the trash because it was permanently deleted.
- */
- isDeleted: boolean;
- /**
- * `true` if the file no longer in trash because it was restored to some
- * collection.
- *
- * This field is relevant when we obtain a trash item as part of the trash
- * diff. It indicates that the file which was previously in trash is no
- * longer in the trash because it was restored to a collection.
- */
- isRestored: boolean;
- deleteBy: number;
- createdAt: number;
- updatedAt: number;
-}
-
-export type Trash = TrashItem[];
-
-/**
- * A short identifier for a file in log messages.
- *
- * e.g. "file flower.png (827233681)"
- *
- * @returns a string to use as an identifier when logging information about the
- * given {@link file}. The returned string contains the file name (for ease of
- * debugging) and the file ID (for exactness).
- */
-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 async function decryptFile(
file: EncryptedEnteFile,
collectionKey: string,
@@ -798,6 +741,28 @@ export const mergeMetadata1 = (file: EnteFile): EnteFile => {
export const mergeMetadata = (files: EnteFile[]) =>
files.map((file) => mergeMetadata1(file));
+/**
+ * A short identifier for a file in log messages.
+ *
+ * e.g. "file flower.png (827233681)"
+ *
+ * @returns a string to use as an identifier when logging information about the
+ * given {@link file}. The returned string contains the file name (for ease of
+ * debugging) and the file ID (for exactness).
+ */
+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/services/collections.ts b/web/packages/new/photos/services/collections.ts
index f04d9320c8..904780279c 100644
--- a/web/packages/new/photos/services/collections.ts
+++ b/web/packages/new/photos/services/collections.ts
@@ -6,17 +6,16 @@
import log from "ente-base/log";
import { apiURL } from "ente-base/origins";
import { type Collection } from "ente-media/collection";
-import {
- decryptFile,
- type EncryptedTrashItem,
- type EnteFile,
- type Trash,
-} from "ente-media/file";
+import { decryptFile, type EnteFile } from "ente-media/file";
import {
getLocalTrash,
getTrashedFiles,
TRASH,
} from "ente-new/photos/services/files";
+import {
+ type EncryptedTrashItem,
+ type Trash,
+} from "ente-new/photos/services/trash";
import HTTPService from "ente-shared/network/HTTPService";
import localForage from "ente-shared/storage/localForage";
import { getToken } from "ente-shared/storage/localStorage/helpers";
diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.ts
index fadbb67c9a..293b9749cb 100644
--- a/web/packages/new/photos/services/files.ts
+++ b/web/packages/new/photos/services/files.ts
@@ -7,9 +7,9 @@ import {
mergeMetadata,
type EncryptedEnteFile,
type EnteFile,
- type Trash,
} from "ente-media/file";
import { metadataHash } from "ente-media/file-metadata";
+import { type Trash } from "ente-new/photos/services/trash";
import HTTPService from "ente-shared/network/HTTPService";
import localForage from "ente-shared/storage/localForage";
import { getToken } from "ente-shared/storage/localStorage/helpers";
diff --git a/web/packages/new/photos/services/trash.ts b/web/packages/new/photos/services/trash.ts
new file mode 100644
index 0000000000..0635e3a37b
--- /dev/null
+++ b/web/packages/new/photos/services/trash.ts
@@ -0,0 +1,31 @@
+import type { EncryptedEnteFile, EnteFile } from "ente-media/file";
+
+export interface TrashItem extends Omit<EncryptedTrashItem, "file"> {
+ file: EnteFile;
+}
+
+export interface EncryptedTrashItem {
+ file: EncryptedEnteFile;
+ /**
+ * `true` if the file no longer in trash because it was permanently deleted.
+ *
+ * This field is relevant when we obtain a trash item as part of the trash
+ * diff. It indicates that the file which was previously in trash is no
+ * longer in the trash because it was permanently deleted.
+ */
+ isDeleted: boolean;
+ /**
+ * `true` if the file no longer in trash because it was restored to some
+ * collection.
+ *
+ * This field is relevant when we obtain a trash item as part of the trash
+ * diff. It indicates that the file which was previously in trash is no
+ * longer in the trash because it was restored to a collection.
+ */
+ isRestored: boolean;
+ deleteBy: number;
+ createdAt: number;
+ updatedAt: number;
+}
+
+export type Trash = TrashItem[];