Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathib1f603d46310
diff --git a/web/apps/photos/src/components/Collections/CollectionSelector.tsx b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
index 0c049a77e4..82cd320868 100644
--- a/web/apps/photos/src/components/Collections/CollectionSelector.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
@@ -7,6 +7,8 @@ import {
} from "@/new/photos/components/ItemCards";
import {
CollectionSummaryOrder,
+ isAddToAllowedCollection,
+ isMoveToAllowedCollection,
type CollectionSummaries,
type CollectionSummary,
} from "@/new/photos/services/collection/ui";
@@ -21,10 +23,6 @@ import {
} from "@mui/material";
import { t } from "i18next";
import { useEffect, useState } from "react";
-import {
- isAddToAllowedCollection,
- isMoveToAllowedCollection,
-} from "utils/collection";
export enum CollectionSelectorIntent {
upload,
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 61529626ce..0d1bf71eda 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -1,4 +1,9 @@
import type { Collection } from "@/media/collection";
+import {
+ hasNonSystemCollections,
+ isSystemCollection,
+ shouldBeShownOnCollectionBar,
+} from "@/new/photos/services/collection/ui";
import {
GalleryBarImpl,
type GalleryBarImplProps,
@@ -29,12 +34,7 @@ import React, {
} from "react";
import { sortCollectionSummaries } from "services/collectionService";
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
-import {
- ALL_SECTION,
- hasNonSystemCollections,
- isSystemCollection,
- shouldBeShownOnCollectionBar,
-} from "utils/collection";
+import { ALL_SECTION } from "utils/collection";
import {
FilesDownloadProgressAttributes,
isFilesDownloadCancelled,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 8c2afde46c..ff7243e133 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -16,6 +16,7 @@ import {
import { WhatsNew } from "@/new/photos/components/WhatsNew";
import { shouldShowWhatsNew } from "@/new/photos/services/changelog";
import type { CollectionSummaries } from "@/new/photos/services/collection/ui";
+import { hasNonSystemCollections } from "@/new/photos/services/collection/ui";
import downloadManager from "@/new/photos/services/download";
import {
getLocalFiles,
@@ -140,7 +141,6 @@ import {
getDefaultHiddenCollectionIDs,
getSelectedCollection,
handleCollectionOps,
- hasNonSystemCollections,
splitNormalAndHiddenCollections,
} from "utils/collection";
import {
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index f06457a670..124a19d327 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -8,10 +8,6 @@ import {
CollectionType,
} from "@/media/collection";
import { ItemVisibility } from "@/media/file-metadata";
-import type {
- CollectionSummaries,
- CollectionSummaryType,
-} from "@/new/photos/services/collection/ui";
import { getAllLocalFiles, getLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import { SUB_TYPE } from "@/new/photos/types/magicMetadata";
@@ -45,43 +41,6 @@ export const DUMMY_UNCATEGORIZED_COLLECTION = -3;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;
-const SYSTEM_COLLECTION_TYPES = new Set<CollectionSummaryType>([
- "all",
- "archive",
- "trash",
- "uncategorized",
- "hiddenItems",
- "defaultHidden",
-]);
-
-const ADD_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
- "all",
- "archive",
- "incomingShareViewer",
- "trash",
- "uncategorized",
- "defaultHidden",
- "hiddenItems",
-]);
-
-const MOVE_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
- "all",
- "archive",
- "incomingShareViewer",
- "incomingShareCollaborator",
- "trash",
- "uncategorized",
- "defaultHidden",
- "hiddenItems",
-]);
-
-const HIDE_FROM_COLLECTION_BAR_TYPES = new Set<CollectionSummaryType>([
- "trash",
- "archive",
- "uncategorized",
- "defaultHidden",
-]);
-
export enum COLLECTION_OPS_TYPE {
ADD,
MOVE,
@@ -385,31 +344,6 @@ export const getDefaultHiddenCollectionIDs = (collections: Collection[]) => {
);
};
-export const hasNonSystemCollections = (
- collectionSummaries: CollectionSummaries,
-) => {
- for (const collectionSummary of collectionSummaries.values()) {
- if (!isSystemCollection(collectionSummary.type)) return true;
- }
- return false;
-};
-
-export const isMoveToAllowedCollection = (type: CollectionSummaryType) => {
- return !MOVE_TO_NOT_ALLOWED_COLLECTION.has(type);
-};
-
-export const isAddToAllowedCollection = (type: CollectionSummaryType) => {
- return !ADD_TO_NOT_ALLOWED_COLLECTION.has(type);
-};
-
-export const isSystemCollection = (type: CollectionSummaryType) => {
- return SYSTEM_COLLECTION_TYPES.has(type);
-};
-
-export const shouldBeShownOnCollectionBar = (type: CollectionSummaryType) => {
- return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
-};
-
export const getUserOwnedCollections = (collections: Collection[]) => {
const user: User = getData(LS_KEYS.USER);
if (!user?.id) {
diff --git a/web/packages/new/photos/services/collection/ui.ts b/web/packages/new/photos/services/collection/ui.ts
index 060a54ea16..62418b1fd7 100644
--- a/web/packages/new/photos/services/collection/ui.ts
+++ b/web/packages/new/photos/services/collection/ui.ts
@@ -76,3 +76,65 @@ export const CollectionSummaryOrder = new Map<CollectionSummaryType, number>([
["trash", 6],
["defaultHidden", 7],
]);
+
+const SYSTEM_COLLECTION_TYPES = new Set<CollectionSummaryType>([
+ "all",
+ "archive",
+ "trash",
+ "uncategorized",
+ "hiddenItems",
+ "defaultHidden",
+]);
+
+const ADD_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
+ "all",
+ "archive",
+ "incomingShareViewer",
+ "trash",
+ "uncategorized",
+ "defaultHidden",
+ "hiddenItems",
+]);
+
+const MOVE_TO_NOT_ALLOWED_COLLECTION = new Set<CollectionSummaryType>([
+ "all",
+ "archive",
+ "incomingShareViewer",
+ "incomingShareCollaborator",
+ "trash",
+ "uncategorized",
+ "defaultHidden",
+ "hiddenItems",
+]);
+
+const HIDE_FROM_COLLECTION_BAR_TYPES = new Set<CollectionSummaryType>([
+ "trash",
+ "archive",
+ "uncategorized",
+ "defaultHidden",
+]);
+
+export const hasNonSystemCollections = (
+ collectionSummaries: CollectionSummaries,
+) => {
+ for (const collectionSummary of collectionSummaries.values()) {
+ if (!isSystemCollection(collectionSummary.type)) return true;
+ }
+ return false;
+};
+
+export const isMoveToAllowedCollection = (type: CollectionSummaryType) => {
+ return !MOVE_TO_NOT_ALLOWED_COLLECTION.has(type);
+};
+
+export const isAddToAllowedCollection = (type: CollectionSummaryType) => {
+ return !ADD_TO_NOT_ALLOWED_COLLECTION.has(type);
+};
+
+export const isSystemCollection = (type: CollectionSummaryType) => {
+ return SYSTEM_COLLECTION_TYPES.has(type);
+};
+
+export const shouldBeShownOnCollectionBar = (type: CollectionSummaryType) => {
+ return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
+};