Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(file-action):add-photos-to-hidden-album

Aswin Asok021dfff470af
diff --git a/web/apps/photos/src/components/SelectedFileOptions.tsx b/web/apps/photos/src/components/SelectedFileOptions.tsx
index 2208bbc50d..27ca534106 100644
--- a/web/apps/photos/src/components/SelectedFileOptions.tsx
+++ b/web/apps/photos/src/components/SelectedFileOptions.tsx
@@ -135,6 +135,7 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
onOpenCollectionSelector({
action: "add",
sourceCollectionSummaryID: collectionSummary?.id,
+ showHiddenCollections: barMode == "hidden-albums",
onCreateCollection: createOnCreateForCollectionOp("add"),
onSelectCollection: createOnSelectForCollectionOp("add"),
});
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 23becfa924..dfb248eaf9 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -111,6 +111,7 @@ import {
addToFavoritesCollection,
canAddFilesToCollection,
createAlbum,
+ createHiddenAlbum,
createPublicURL,
createQuickLinkCollection,
removeFromCollection,
@@ -257,6 +258,9 @@ const Page: React.FC = () => {
const [, setPostCreateAlbumOp] = useState<CollectionOp | undefined>(
undefined,
);
+ // Albums created for an "add" that originated in the hidden section must
+ // themselves be hidden, otherwise the added files would become visible.
+ const postCreateAlbumHidden = useRef(false);
const [pendingSidebarAction, setPendingSidebarAction] = useState<
SidebarActionID | undefined
>(undefined);
@@ -981,15 +985,19 @@ const Page: React.FC = () => {
const createOnCreateForCollectionOp = useCallback(
(op: CollectionOp) => {
setPostCreateAlbumOp(op);
+ postCreateAlbumHidden.current =
+ op == "add" && barMode == "hidden-albums";
return showAlbumNameInput;
},
- [showAlbumNameInput],
+ [showAlbumNameInput, barMode],
);
const handleAlbumNameSubmit = useCallback(
async (name: string) => {
try {
- const collection = await createAlbum(name);
+ const collection = postCreateAlbumHidden.current
+ ? await createHiddenAlbum(name)
+ : await createAlbum(name);
if (pendingSingleFileAdd.current) {
await performCollectionOp(
@@ -1022,6 +1030,7 @@ const Page: React.FC = () => {
});
} finally {
pendingSingleFileAdd.current = undefined;
+ postCreateAlbumHidden.current = false;
}
},
[createOnSelectForCollectionOp, remotePull],
@@ -1598,6 +1607,7 @@ const Page: React.FC = () => {
handleOpenCollectionSelector({
action: "add",
sourceCollectionSummaryID: activeCollectionSummary?.id,
+ showHiddenCollections: barMode == "hidden-albums",
onCreateCollection:
createOnCreateForCollectionOp("add"),
onSelectCollection:
@@ -1701,6 +1711,7 @@ const Page: React.FC = () => {
showEditLocation,
activeCollectionSummary,
activeCollection,
+ barMode,
selectedCount,
selectedOwnCount,
],
@@ -1749,6 +1760,7 @@ const Page: React.FC = () => {
const handleCreate = () => {
setPostCreateAlbumOp("add");
+ postCreateAlbumHidden.current = false;
showAlbumNameInput();
};
diff --git a/web/apps/photos/src/utils/file-actions.ts b/web/apps/photos/src/utils/file-actions.ts
index 7ff8430d6e..74b4d552b8 100644
--- a/web/apps/photos/src/utils/file-actions.ts
+++ b/web/apps/photos/src/utils/file-actions.ts
@@ -127,7 +127,7 @@ function getBaseActions(
}
if (barMode === "hidden-albums") {
- return ["download", "unhide", "trash"];
+ return ["download", "addToAlbum", "unhide", "trash"];
}
const isUserFavorites =