Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web] Prioritize active collection in upload to album dialog

Anand Baburajan02f32e4338d8
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 809a661c1d..ff4eb13dae 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -591,6 +591,7 @@ export const Upload: React.FC<UploadProps> = ({
onOpenCollectionSelector?.({
action: "upload",
+ activeCollectionID: props.activeCollection?.id,
onSelectCollection: uploadFilesToExistingCollection,
onCreateCollection: showNextModal,
onCancel: handleCollectionSelectorCancel,
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index d3d576233f..6947208595 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -53,6 +53,13 @@ export interface CollectionSelectorAttributes {
* {@link sourceCollectionID} to omit showing it in the list again.
*/
sourceCollectionSummaryID?: number;
+ /**
+ * If set, this collection will be shown first in the list.
+ *
+ * This is useful for the "upload" action, where the user is viewing a
+ * specific collection and might want to upload to it.
+ */
+ activeCollectionID?: number;
/**
* Callback invoked when the user selects the option to create a new
* collection.
@@ -135,6 +142,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
return;
}
+ const activeCollectionID = attributes.activeCollectionID;
const collections = [...collectionSummaries.values()]
.filter((cs) => {
if (cs.id === attributes.sourceCollectionSummaryID) {
@@ -161,7 +169,13 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
}
})
.sort((a, b) => a.name.localeCompare(b.name))
- .sort((a, b) => b.sortPriority - a.sortPriority);
+ .sort((a, b) => b.sortPriority - a.sortPriority)
+ .sort((a, b) => {
+ // Prioritize the active collection (if any) to appear first.
+ if (a.id === activeCollectionID) return -1;
+ if (b.id === activeCollectionID) return 1;
+ return 0;
+ });
if (collections.length === 0) {
onClose();