Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathife473bcd0a7c
diff --git a/web/apps/photos/src/components/Collections/CollectionSelector.tsx b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
index b8ad8226db..1e18e9d1a0 100644
--- a/web/apps/photos/src/components/Collections/CollectionSelector.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
@@ -5,9 +5,10 @@ import {
ItemTileOverlay,
LargeTileTextOverlay,
} from "@/new/photos/components/ItemCards";
-import type {
- CollectionSummaries,
- CollectionSummary,
+import {
+ CollectionSummaryOrder,
+ type CollectionSummaries,
+ type CollectionSummary,
} from "@/new/photos/types/collection";
import { FlexWrapper } from "@ente/shared/components/Container";
import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
@@ -22,7 +23,6 @@ import { t } from "i18next";
import { useEffect, useState } from "react";
import { createUnCategorizedCollection } from "services/collectionService";
import {
- COLLECTION_SORT_ORDER,
DUMMY_UNCATEGORIZED_COLLECTION,
isAddToAllowedCollection,
isMoveToAllowedCollection,
@@ -109,8 +109,8 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
})
.sort((a, b) => {
return (
- COLLECTION_SORT_ORDER.get(a.type) -
- COLLECTION_SORT_ORDER.get(b.type)
+ CollectionSummaryOrder.get(a.type) -
+ CollectionSummaryOrder.get(b.type)
);
});
if (collectionsToShow.length === 0) {
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 66d8e153cb..5cc7f68e79 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -25,7 +25,7 @@ import type {
CollectionSummary,
CollectionSummaryType,
} from "@/new/photos/types/collection";
-import { CollectionsSortBy } from "@/new/photos/types/collection";
+import { CollectionsSortBy, CollectionSummaryOrder } from "@/new/photos/types/collection";
import { EnteFile } from "@/new/photos/types/file";
import {
EncryptedMagicMetadata,
@@ -45,7 +45,6 @@ import { FamilyData } from "types/user";
import {
ALL_SECTION,
ARCHIVE_SECTION,
- COLLECTION_SORT_ORDER,
DUMMY_UNCATEGORIZED_COLLECTION,
HIDDEN_ITEMS_SECTION,
TRASH_SECTION,
@@ -1089,8 +1088,8 @@ export const sortCollectionSummaries = (
.sort((a, b) => b.order ?? 0 - a.order ?? 0)
.sort(
(a, b) =>
- COLLECTION_SORT_ORDER.get(a.type) -
- COLLECTION_SORT_ORDER.get(b.type),
+ CollectionSummaryOrder.get(a.type) -
+ CollectionSummaryOrder.get(b.type),
);
function compareCollectionsLatestFile(first: EnteFile, second: EnteFile) {
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index 1809b074e5..f86f4b0a45 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -45,23 +45,7 @@ export const DUMMY_UNCATEGORIZED_COLLECTION = -3;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;
-export const COLLECTION_SORT_ORDER = new Map<CollectionSummaryType, number>([
- ["all", 0],
- ["hiddenItems", 0],
- ["uncategorized", 1],
- ["favorites", 2],
- ["pinned", 3],
- ["album", 4],
- ["folder", 4],
- ["incomingShareViewer", 4],
- ["incomingShareCollaborator", 4],
- ["outgoingShare", 4],
- ["sharedOnlyViaLink", 4],
- ["archived", 4],
- ["archive", 5],
- ["trash", 6],
- ["defaultHidden", 7],
-]);
+
const SYSTEM_COLLECTION_TYPES = new Set<CollectionSummaryType>([
"all",
diff --git a/web/packages/new/photos/types/collection.ts b/web/packages/new/photos/types/collection.ts
index 60e8cad03f..060a54ea16 100644
--- a/web/packages/new/photos/types/collection.ts
+++ b/web/packages/new/photos/types/collection.ts
@@ -52,3 +52,27 @@ export const collectionsSortBy = [
* Type of individual {@link collectionsSortBy} values.
*/
export type CollectionsSortBy = (typeof collectionsSortBy)[number];
+
+/**
+ * An ordering of collection "categories".
+ *
+ * Within each category, the collections are sorted by the applicable
+ * {@link CollectionsSortBy}.
+ */
+export const CollectionSummaryOrder = new Map<CollectionSummaryType, number>([
+ ["all", 0],
+ ["hiddenItems", 0],
+ ["uncategorized", 1],
+ ["favorites", 2],
+ ["pinned", 3],
+ ["album", 4],
+ ["folder", 4],
+ ["incomingShareViewer", 4],
+ ["incomingShareCollaborator", 4],
+ ["outgoingShare", 4],
+ ["sharedOnlyViaLink", 4],
+ ["archived", 4],
+ ["archive", 5],
+ ["trash", 6],
+ ["defaultHidden", 7],
+]);