Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv

Manav Rathi5ee16e992b83
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<CollectionHeaderProps> = ({
case "incomingShareViewer":
case "incomingShareCollaborator":
menuOptions = [
- isArchivedCollection(activeCollection) ? (
+ collectionSummary.attributes.has("archived") ? (
<OverflowMenuOption
key="unarchive"
onClick={unarchiveAlbum}
@@ -437,7 +436,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
),
...(!isHiddenCollection(activeCollection)
? [
- isArchivedCollection(activeCollection) ? (
+ collectionSummary.attributes.has("archived") ? (
<OverflowMenuOption
key="unarchive"
onClick={unarchiveAlbum}
diff --git a/web/packages/gallery/services/magic-metadata.ts b/web/packages/gallery/services/magic-metadata.ts
deleted file mode 100644
index c2051fd108..0000000000
--- a/web/packages/gallery/services/magic-metadata.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// TODO: Review this file
-/* eslint-disable @typescript-eslint/prefer-optional-chain */
-/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-import type { Collection } from "ente-media/collection";
-import { ItemVisibility } from "ente-media/file-metadata";
-
-export const isArchivedCollection = (item: Collection) => {
- 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.