Skip to content

armgit / ente

Public Imported from GitHub
0

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

Tweak

Manav Rathi99b379280f13
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index ecb456bf4f..6fea90561d 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -125,7 +125,7 @@ import {
SetFilesDownloadProgressAttributes,
SetFilesDownloadProgressAttributesCreator,
} from "types/gallery";
-import { getSelectedCollection, handleCollectionOp } from "utils/collection";
+import { handleCollectionOp } from "utils/collection";
import { getSelectedFiles, handleFileOp } from "utils/file";
/**
@@ -924,9 +924,8 @@ const Page: React.FC = () => {
barMode={barMode}
isInSearchMode={isInSearchMode}
activeCollectionID={activeCollectionID}
- selectedCollection={getSelectedCollection(
- selected.collectionID,
- state.collections,
+ selectedCollection={state.collections.find(
+ (c) => c.id == selected.collectionID,
)}
activeCollectionSummary={activeCollectionSummary}
count={selected.count}
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index 532b4204be..06bd94a016 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -59,13 +59,6 @@ export async function handleCollectionOp(
}
}
-export function getSelectedCollection(
- collectionID: number,
- collections: Collection[],
-) {
- return collections.find((collection) => collection.id === collectionID);
-}
-
export async function downloadCollectionHelper(
collectionID: number,
setFilesDownloadProgressAttributes: SetFilesDownloadProgressAttributes,
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index 78e913b0b6..0c53f4d38d 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -39,6 +39,14 @@ export interface CollectionSelectorAttributes {
* particular action.
*/
action: CollectionSelectorAction;
+ /**
+ * Some actions, like "add" and "move", happen in the context of an existing
+ * collection summary.
+ *
+ * In such cases, the ID of the collection summary can be set as the
+ * {@link sourceCollectionID} to omit showing it in the list again.
+ */
+ sourceCollectionSummaryID?: number;
/**
* Callback invoked when the user selects one the existing collections
* listed in the dialog.
@@ -53,12 +61,6 @@ export interface CollectionSelectorAttributes {
* Callback invoked when the user cancels the collection selection dialog.
*/
onCancel?: () => void;
- /**
- * Some actions, like "add" and "move", happen in the context of an existing
- * collection. In such cases, the ID of this collection can be set as the
- * {@link relatedCollectionID} to omit showing it in the list again.
- */
- relatedCollectionID?: number | undefined;
}
type CollectionSelectorProps = ModalVisibilityProps & {
@@ -123,7 +125,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
const collections = [...collectionSummaries.values()]
.filter((cs) => {
- if (cs.id === attributes.relatedCollectionID) {
+ if (cs.id === attributes.sourceCollectionID) {
return false;
} else if (attributes.action == "add") {
return canAddToCollection(cs);
diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsx
index 7b321ff2e1..bae9294a80 100644
--- a/web/packages/new/photos/components/SelectedFileOptions.tsx
+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx
@@ -82,6 +82,10 @@ interface SelectedFileOptionsProps {
clearSelection: () => void;
}
+/**
+ * The selection bar shown at the top of the viewport when the user has selected
+ * one or more files in the photos app gallery.
+ */
export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
barMode,
isInSearchMode,
@@ -107,6 +111,14 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
const isSharedIncomingCollection =
!!activeCollectionSummary?.attributes.has("sharedIncoming");
+ const handleUnhide = () => {
+ onOpenCollectionSelector({
+ action: "unhide",
+ onSelectCollection: handleCollectionOp("unhide"),
+ onCreateCollection: showCreateCollectionModal("unhide"),
+ });
+ };
+
const handleDelete = () =>
showMiniDialog({
title: t("trash_files_title"),
@@ -139,12 +151,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
const handleAddToCollection = () =>
onOpenCollectionSelector({
action: "add",
+ sourceCollectionSummaryID: activeCollectionSummary?.id,
onSelectCollection: handleCollectionOp("add"),
onCreateCollection: showCreateCollectionModal("add"),
- relatedCollectionID:
- isInSearchMode || barMode == "people"
- ? undefined
- : activeCollectionID,
});
const handleRemoveFromOwnCollection = () => {
@@ -176,20 +185,9 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
const handleMoveToCollection = () => {
onOpenCollectionSelector({
action: "move",
+ sourceCollectionSummaryID: activeCollectionSummary?.id,
onSelectCollection: handleCollectionOp("move"),
onCreateCollection: showCreateCollectionModal("move"),
- relatedCollectionID:
- isInSearchMode || barMode == "people"
- ? undefined
- : activeCollectionID,
- });
- };
-
- const unhideToCollection = () => {
- onOpenCollectionSelector({
- action: "unhide",
- onSelectCollection: handleCollectionOp("unhide"),
- onCreateCollection: showCreateCollectionModal("unhide"),
});
};
@@ -241,7 +239,7 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
<DownloadButton onClick={handleFileOp("download")} />
) : barMode == "hidden-albums" ? (
<>
- <UnhideButton onClick={unhideToCollection} />
+ <UnhideButton onClick={handleUnhide} />
<DownloadButton onClick={handleFileOp("download")} />
<DeleteButton onClick={handleDelete} />
</>