This commit is contained in:
Manav Rathi
2025-06-27 15:12:27 +05:30
parent ad269fe995
commit 5ee16e992b
4 changed files with 20 additions and 27 deletions

View File

@@ -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}

View File

@@ -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;
};

View File

@@ -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";

View File

@@ -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.