Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathi6b965b1aa6f7
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 31ee389976..6e768917ae 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -25,10 +25,7 @@ import {
import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
import { useModalVisibility } from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
-import {
- isArchivedCollection,
- isPinnedCollection,
-} from "ente-gallery/services/magic-metadata";
+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";
@@ -421,7 +418,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
>
{t("sort_by")}
</OverflowMenuOption>,
- isPinnedCollection(activeCollection) ? (
+ collectionSummary.attributes.has("pinned") ? (
<OverflowMenuOption
key="unpin"
onClick={unpinAlbum}
diff --git a/web/apps/photos/src/services/publicCollectionService.ts b/web/apps/photos/src/services/publicCollectionService.ts
index fa27c53fcc..505816af59 100644
--- a/web/apps/photos/src/services/publicCollectionService.ts
+++ b/web/apps/photos/src/services/publicCollectionService.ts
@@ -2,7 +2,6 @@ import { sharedCryptoWorker } from "ente-base/crypto";
import log from "ente-base/log";
import { apiURL } from "ente-base/origins";
import { transformFilesIfNeeded } from "ente-gallery/services/files-db";
-import { type MagicMetadataCore } from "ente-gallery/services/magic-metadata";
import { sortFiles } from "ente-gallery/utils/file";
import type {
Collection,
@@ -308,6 +307,13 @@ const getPublicFiles = async (
}
};
+export interface MagicMetadataCore<T> {
+ version: number;
+ count: number;
+ header: string;
+ data: T;
+}
+
export const getPublicCollection = async (
token: string,
collectionKey: string,
diff --git a/web/packages/gallery/services/magic-metadata.ts b/web/packages/gallery/services/magic-metadata.ts
index f3c6fe7352..c2051fd108 100644
--- a/web/packages/gallery/services/magic-metadata.ts
+++ b/web/packages/gallery/services/magic-metadata.ts
@@ -4,13 +4,6 @@
import type { Collection } from "ente-media/collection";
import { ItemVisibility } from "ente-media/file-metadata";
-export interface MagicMetadataCore<T> {
- version: number;
- count: number;
- header: string;
- data: T;
-}
-
export const isArchivedCollection = (item: Collection) => {
if (!item) {
return false;
@@ -27,16 +20,3 @@ export const isArchivedCollection = (item: Collection) => {
}
return false;
};
-
-export function isPinnedCollection(item: Collection) {
- if (
- !item ||
- !item.magicMetadata ||
- !item.magicMetadata.data ||
- typeof item.magicMetadata.data == "string" ||
- typeof item.magicMetadata.data.order == "undefined"
- ) {
- return false;
- }
- return item.magicMetadata.data.order !== 0;
-}
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index 5e9fafac81..8ff91f4352 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -1,14 +1,15 @@
import type { User } from "ente-accounts/services/user";
-import {
- isArchivedCollection,
- isPinnedCollection,
-} from "ente-gallery/services/magic-metadata";
+import { isArchivedCollection } from "ente-gallery/services/magic-metadata";
import {
groupFilesByCollectionID,
sortFiles,
uniqueFilesByID,
} from "ente-gallery/utils/file";
-import { collectionTypes, type Collection } from "ente-media/collection";
+import {
+ CollectionOrder,
+ collectionTypes,
+ type Collection,
+} from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
import {
isArchivedFile,
@@ -1405,7 +1406,9 @@ const createCollectionSummaries = (
type = "archived";
} else if (isDefaultHiddenCollection(collection)) {
type = "defaultHidden";
- } else if (isPinnedCollection(collection)) {
+ } else if (
+ collection.magicMetadata?.data.order == CollectionOrder.pinned
+ ) {
type = "pinned";
} else {
type = collectionType;
@@ -1434,7 +1437,7 @@ const createCollectionSummaries = (
if (isDefaultHiddenCollection(collection)) {
attributes.add("defaultHidden");
}
- if (isPinnedCollection(collection)) {
+ if (collection.magicMetadata?.data.order == CollectionOrder.pinned) {
attributes.add("pinned");
}
switch (collectionType) {