diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx index 4efe6a64cf..a08a7b38cd 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx @@ -1,5 +1,5 @@ import log from "@/base/log"; -import { ItemVisibility } from "@/new/photos/types/magicMetadata"; +import { ItemVisibility } from "@/media/file-metadata"; import { HorizontalFlex } from "@ente/shared/components/Container"; import OverflowMenu from "@ente/shared/components/OverflowMenu/menu"; import MoreHoriz from "@mui/icons-material/MoreHoriz"; diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts index fd46955960..8632821b6a 100644 --- a/web/apps/photos/src/services/collectionService.ts +++ b/web/apps/photos/src/services/collectionService.ts @@ -4,10 +4,10 @@ import { getLocalFiles } from "@/new/photos/services/files"; import { EnteFile } from "@/new/photos/types/file"; import { EncryptedMagicMetadata, - ItemVisibility, SUB_TYPE, UpdateMagicMetadataRequest, } from "@/new/photos/types/magicMetadata"; +import { ItemVisibility } from "@/media/file-metadata"; import { batch } from "@/utils/array"; import ComlinkCryptoWorker from "@ente/shared/crypto"; import { CustomError } from "@ente/shared/error"; diff --git a/web/apps/photos/src/types/collection/index.ts b/web/apps/photos/src/types/collection/index.ts index 1165c150ed..4997cd73de 100644 --- a/web/apps/photos/src/types/collection/index.ts +++ b/web/apps/photos/src/types/collection/index.ts @@ -1,7 +1,7 @@ +import { ItemVisibility } from "@/media/file-metadata"; import { EnteFile } from "@/new/photos/types/file"; import { EncryptedMagicMetadata, - ItemVisibility, MagicMetadataCore, SUB_TYPE, } from "@/new/photos/types/magicMetadata"; diff --git a/web/apps/photos/src/utils/collection/index.ts b/web/apps/photos/src/utils/collection/index.ts index b7bc1a5780..b3393da69f 100644 --- a/web/apps/photos/src/utils/collection/index.ts +++ b/web/apps/photos/src/utils/collection/index.ts @@ -1,8 +1,9 @@ import { ensureElectron } from "@/base/electron"; import log from "@/base/log"; +import { ItemVisibility } from "@/media/file-metadata"; import { getAllLocalFiles, getLocalFiles } from "@/new/photos/services/files"; import { EnteFile } from "@/new/photos/types/file"; -import { ItemVisibility, SUB_TYPE } from "@/new/photos/types/magicMetadata"; +import { SUB_TYPE } from "@/new/photos/types/magicMetadata"; import { safeDirectoryName } from "@/new/photos/utils/native-fs"; import { CustomError } from "@ente/shared/error"; import { LS_KEYS, getData } from "@ente/shared/storage/localStorage"; diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts index c1eef9c03d..71978ee24c 100644 --- a/web/apps/photos/src/utils/file/index.ts +++ b/web/apps/photos/src/utils/file/index.ts @@ -1,5 +1,6 @@ import log from "@/base/log"; import { type Electron } from "@/base/types/ipc"; +import { ItemVisibility } from "@/media/file-metadata"; import { FileType } from "@/media/file-type"; import { decodeLivePhoto } from "@/media/live-photo"; import DownloadManager from "@/new/photos/services/download"; @@ -13,7 +14,6 @@ import { FilePublicMagicMetadataProps, FileWithUpdatedMagicMetadata, } from "@/new/photos/types/file"; -import { ItemVisibility } from "@/new/photos/types/magicMetadata"; import { detectFileTypeInfo } from "@/new/photos/utils/detect-type"; import { mergeMetadata } from "@/new/photos/utils/file"; import { safeFileName } from "@/new/photos/utils/native-fs"; diff --git a/web/apps/photos/src/utils/magicMetadata/index.ts b/web/apps/photos/src/utils/magicMetadata/index.ts index 0fa10a5146..2d80b486d2 100644 --- a/web/apps/photos/src/utils/magicMetadata/index.ts +++ b/web/apps/photos/src/utils/magicMetadata/index.ts @@ -1,8 +1,6 @@ +import { ItemVisibility } from "@/media/file-metadata"; import { EnteFile } from "@/new/photos/types/file"; -import { - ItemVisibility, - MagicMetadataCore, -} from "@/new/photos/types/magicMetadata"; +import { MagicMetadataCore } from "@/new/photos/types/magicMetadata"; import ComlinkCryptoWorker from "@ente/shared/crypto"; import { Collection } from "types/collection"; diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.ts index 0554a64fd3..cecbe8765f 100644 --- a/web/packages/media/file-metadata.ts +++ b/web/packages/media/file-metadata.ts @@ -88,13 +88,50 @@ export interface Metadata { } /** - * Mutable metadata associated with an {@link EnteFile}. + * Mutable private metadata associated with an {@link EnteFile}. * * - Unlike {@link Metadata}, this can change after the file has been * uploaded. * - * - Unlike {@link MagicMetadata}, this is available to all the people with - * whom the file has been shared. + * - Unlike {@link PublicMagicMetadata}, this is only available to the owner + * of the file. + * + * For historical reasons, the unqualified phrase "magic metadata" in various + * APIs refers to the (this) private metadata, even though the mutable public + * metadata is the much more frequently used of the two. See: [Note: Metadatum]. + */ +export interface PrivateMagicMetadata { + /** + * The visibility of the file. + * + * The file's visibility is user specific attribute, and thus we keep it in + * the private magic metadata. This allows the file's owner to share a file + * and independently edit its visibility without revealing their visibility + * preference to the other people with whom they have shared the file. + */ + visibility?: ItemVisibility; +} + +/** + * The visibility of an Ente file or collection. + */ +export enum ItemVisibility { + /** The normal state - The item is visible. */ + visible = 0, + /** The item has been archived. */ + archived = 1, + /** The item has been hidden. */ + hidden = 2, +} + +/** + * Mutable public metadata associated with an {@link EnteFile}. + * + * - Unlike {@link Metadata}, this can change after the file has been + * uploaded. + * + * - Unlike {@link PrivateMagicMetadata}, this is available to all the people + * with whom the file has been shared. * * For more details, see [Note: Metadatum]. */ @@ -200,7 +237,7 @@ export type EncryptMetadataF = typeof encryptMetadata; */ export const updateMagicMetadataRequest = async ( enteFile: EnteFile, - metadata: PublicMagicMetadata, + metadata: PrivateMagicMetadata | PublicMagicMetadata, metadataVersion: number, encryptMetadataF: EncryptMetadataF, ): Promise => { diff --git a/web/packages/new/photos/types/file.ts b/web/packages/new/photos/types/file.ts index 401dbdf098..aff511a337 100644 --- a/web/packages/new/photos/types/file.ts +++ b/web/packages/new/photos/types/file.ts @@ -1,6 +1,5 @@ -import type { Metadata } from "@/media/file-metadata"; +import { type Metadata, ItemVisibility } from "@/media/file-metadata"; import { - ItemVisibility, type EncryptedMagicMetadata, type MagicMetadataCore, } from "./magicMetadata"; diff --git a/web/packages/new/photos/types/magicMetadata.ts b/web/packages/new/photos/types/magicMetadata.ts index 92d0a20986..b96e700aff 100644 --- a/web/packages/new/photos/types/magicMetadata.ts +++ b/web/packages/new/photos/types/magicMetadata.ts @@ -7,18 +7,6 @@ export interface MagicMetadataCore { export type EncryptedMagicMetadata = MagicMetadataCore; -/** - * The visibility of an Ente file or collection. - */ -export enum ItemVisibility { - /** The normal state - The item is visible. */ - visible = 0, - /** The item has been archived. */ - archived = 1, - /** The item has been hidden. */ - hidden = 2, -} - export enum SUB_TYPE { DEFAULT = 0, DEFAULT_HIDDEN = 1,