Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(gallery):add-confirmation-modal-for-moving-to-album

Aswin Asokaee0b6ccc129
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index f0fea86e25..d612100223 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -1262,6 +1262,9 @@ const Page: React.FC = () => {
[],
);
+ const selectedCount = selected.count;
+ const selectedOwnCount = selected.ownCount;
+
/**
* Handle a context menu action on a file.
*
@@ -1342,11 +1345,68 @@ const Page: React.FC = () => {
createOnSelectForCollectionOp("move"),
});
break;
- case "removeFromAlbum":
- if (activeCollection) {
+ case "removeFromAlbum": {
+ if (!activeCollection) break;
+ const isSharedIncoming =
+ activeCollectionSummary?.attributes.has(
+ "sharedIncoming",
+ );
+ const isSharedOutgoing =
+ activeCollectionSummary?.attributes.has(
+ "sharedOutgoing",
+ );
+ const isRemovingOthers =
+ selectedCount != selectedOwnCount;
+ const remove = () =>
handleRemoveFilesFromCollection(activeCollection);
+
+ if (isSharedIncoming) {
+ if (isRemovingOthers) {
+ showMiniDialog({
+ title: t("remove_from_album"),
+ message: t(
+ "remove_from_album_others_message",
+ ),
+ continue: {
+ text: t("remove"),
+ color: "critical",
+ action: remove,
+ },
+ cancel: t("cancel"),
+ });
+ } else {
+ remove();
+ }
+ break;
+ }
+
+ if (isSharedOutgoing && isRemovingOthers) {
+ showMiniDialog({
+ title: t("remove_from_album"),
+ message: t("remove_from_album_others_message"),
+ continue: {
+ text: t("remove"),
+ color: "critical",
+ action: remove,
+ },
+ });
+ break;
}
+
+ const onlyUserFiles = !isRemovingOthers;
+ showMiniDialog({
+ title: t("remove_from_album"),
+ message: onlyUserFiles
+ ? t("confirm_remove_message")
+ : t("confirm_remove_incl_others_message"),
+ continue: {
+ text: t("yes_remove"),
+ color: onlyUserFiles ? "primary" : "critical",
+ action: remove,
+ },
+ });
break;
+ }
case "unhide":
handleOpenCollectionSelector({
action: "unhide",
@@ -1375,6 +1435,8 @@ const Page: React.FC = () => {
showEditLocation,
activeCollectionSummary,
activeCollection,
+ selectedCount,
+ selectedOwnCount,
],
);
diff --git a/web/packages/wasm/Cargo.lock b/web/packages/wasm/Cargo.lock
index 80fabb4abb..6347f292e6 100644
--- a/web/packages/wasm/Cargo.lock
+++ b/web/packages/wasm/Cargo.lock
@@ -285,6 +285,7 @@ dependencies = [
"base64",
"blake2b_simd",
"crypto_secretstream",
+ "getrandom 0.2.16",
"hex",
"md-5",
"rand_core 0.6.4",