Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move up

Manav Rathi68c28df945b9
diff --git a/web/apps/photos/src/components/Collections/CollectionSelector.tsx b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
index 1e18e9d1a0..f4e39b63dc 100644
--- a/web/apps/photos/src/components/Collections/CollectionSelector.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionSelector.tsx
@@ -21,9 +21,7 @@ import {
} from "@mui/material";
import { t } from "i18next";
import { useEffect, useState } from "react";
-import { createUnCategorizedCollection } from "services/collectionService";
import {
- DUMMY_UNCATEGORIZED_COLLECTION,
isAddToAllowedCollection,
isMoveToAllowedCollection,
} from "utils/collection";
@@ -52,8 +50,15 @@ interface CollectionSelectorProps {
open: boolean;
onClose: () => void;
attributes: CollectionSelectorAttributes;
- collections: Collection[];
collectionSummaries: CollectionSummaries;
+ /**
+ * A function to map from a collection ID to a {@link Collection}.
+ *
+ * This is invoked when the user makes a selection, to convert the ID of the
+ * selected collection into a collection object that can be passed to the
+ * {@link callback} attribute of {@link CollectionSelectorAttributes}.
+ */
+ collectionForCollectionID: (collectionID: number) => Promise<Collection>;
}
/**
@@ -63,7 +68,7 @@ interface CollectionSelectorProps {
export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
attributes,
collectionSummaries,
- collections,
+ collectionForCollectionID,
...props
}) => {
// Make the dialog fullscreen if the screen is <= the dialog's max width.
@@ -127,15 +132,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
}
const handleCollectionClick = async (collectionID: number) => {
- let selectedCollection: Collection;
- if (collectionID === DUMMY_UNCATEGORIZED_COLLECTION) {
- const uncategorizedCollection =
- await createUnCategorizedCollection();
- selectedCollection = uncategorizedCollection;
- } else {
- selectedCollection = collections.find((c) => c.id === collectionID);
- }
- attributes.callback(selectedCollection);
+ attributes.callback(await collectionForCollectionID(collectionID));
props.onClose();
};
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index f6311a5b3f..a0aa72b92b 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -1177,7 +1177,12 @@ export default function Gallery() {
onClose={closeCollectionSelector}
collectionSummaries={collectionSummaries}
attributes={collectionSelectorAttributes}
- collections={collections}
+ collectionForCollectionID={(id) =>
+ findCollectionCreatingUncategorizedIfNeeded(
+ collections,
+ id,
+ )
+ }
/>
<FilesDownloadProgress
attributesList={filesDownloadProgressAttributesList}
@@ -1188,6 +1193,7 @@ export default function Gallery() {
hide={() => setFixCreationTimeView(false)}
attributes={fixCreationTimeAttributes}
/>
+
<NavbarBase
sx={{
background: "transparent",
@@ -1469,7 +1475,7 @@ const HiddenSectionNavbarContents: React.FC<
* given {@link collectionID}. As a special case, if collection ID is the
* placeholder ID of the uncategorized collection, create it and then return it.
*/
-const findCollectionByCreatingUncategorizedIfNeeded = async (
+const findCollectionCreatingUncategorizedIfNeeded = async (
collections: Collection[],
collectionID: number,
) => {