From 5ee16e992b83b08fc00ca684c5637ea97c1688d5 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 27 Jun 2025 15:12:27 +0530 Subject: [PATCH] Conv --- .../Collections/CollectionHeader.tsx | 5 ++--- .../gallery/services/magic-metadata.ts | 22 ------------------- .../new/photos/components/gallery/reducer.ts | 2 +- .../new/photos/services/collection.ts | 18 ++++++++++++++- 4 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 web/packages/gallery/services/magic-metadata.ts diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx index 6e768917ae..edf74db137 100644 --- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx +++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx @@ -25,7 +25,6 @@ import { import { SingleInputDialog } from "ente-base/components/SingleInputDialog"; import { useModalVisibility } from "ente-base/components/utils/modal"; import { useBaseContext } from "ente-base/context"; -import { isArchivedCollection } from "ente-gallery/services/magic-metadata"; import { CollectionOrder, type Collection } from "ente-media/collection"; import { ItemVisibility } from "ente-media/file-metadata"; import type { RemotePullOpts } from "ente-new/photos/components/gallery"; @@ -368,7 +367,7 @@ const CollectionHeaderOptions: React.FC = ({ case "incomingShareViewer": case "incomingShareCollaborator": menuOptions = [ - isArchivedCollection(activeCollection) ? ( + collectionSummary.attributes.has("archived") ? ( = ({ ), ...(!isHiddenCollection(activeCollection) ? [ - isArchivedCollection(activeCollection) ? ( + collectionSummary.attributes.has("archived") ? ( { - if (!item) { - return false; - } - - if (item.magicMetadata && item.magicMetadata.data) { - return item.magicMetadata.data.visibility === ItemVisibility.archived; - } - - if (item.sharedMagicMetadata && item.sharedMagicMetadata.data) { - return ( - item.sharedMagicMetadata.data.visibility === ItemVisibility.archived - ); - } - return false; -}; diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts index 024097da2c..6369b2ed0d 100644 --- a/web/packages/new/photos/components/gallery/reducer.ts +++ b/web/packages/new/photos/components/gallery/reducer.ts @@ -1,5 +1,4 @@ import type { User } from "ente-accounts/services/user"; -import { isArchivedCollection } from "ente-gallery/services/magic-metadata"; import { groupFilesByCollectionID, sortFiles, @@ -18,6 +17,7 @@ import { import type { MagicMetadata } from "ente-media/magic-metadata"; import { createCollectionNameByID, + isArchivedCollection, isHiddenCollection, } from "ente-new/photos/services/collection"; import { sortTrashItems, type TrashItem } from "ente-new/photos/services/trash"; diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts index 307a312f2c..25bb9bfa31 100644 --- a/web/packages/new/photos/services/collection.ts +++ b/web/packages/new/photos/services/collection.ts @@ -696,7 +696,7 @@ export const deleteFromTrash = async (fileIDs: number[]) => * * The move operation is not supported across ownership boundaries. The remove * operation is only supported across ownership boundaries, but the user should - * have owner ship of either the file or collection (not both). + * have ownership of either the file or collection (not both). * * In more detail, the above three scenarios can be described this way. * @@ -1184,9 +1184,25 @@ export const findDefaultHiddenCollectionIDs = (collections: Collection[]) => .map((collection) => collection.id), ); +/** + * Return `true` if the given collection is hidden. + * + * Hidden collections are those that have their visibility set to hidden in the + * collection's owner's private magic metadata. + */ export const isHiddenCollection = (collection: Collection) => collection.magicMetadata?.data.visibility == ItemVisibility.hidden; +/** + * Return `true` if the given collection is archived. + * + * Archived collections are those that have their visibility set to hidden in the + * collection's private magic metadata or per-sharee private metadata. + */ +export const isArchivedCollection = (collection: Collection) => + collection.magicMetadata?.data.visibility == ItemVisibility.archived || + collection.sharedMagicMetadata?.data.visibility == ItemVisibility.archived; + /** * Hide the provided {@link files} by moving them to the default hidden * collection.