π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web] Hide gallery deletion when no selected files are owned
Aswin Asokb46a131ef04c
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex cbbd0cd132..e7c1349586 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -484,15 +484,18 @@ export const FileList: React.FC<FileListProps> = ({previousSelectionRef.current !== null;let selectionCount: number;let favoriteCount: number;+ let hasOwnFiles: boolean;let hasOnlyOwnFiles: boolean;if (isTemporarySingleSelection) {selectionCount = 1;favoriteCount = favoriteFileIDs?.has(contextMenu.file.id) ? 1 : 0;hasOnlyOwnFiles = contextMenu.file.ownerID === user?.id;+ hasOwnFiles = hasOnlyOwnFiles;} else {selectionCount = selected.count;favoriteCount = selectedFavoriteCount;+ hasOwnFiles = selected.ownCount > 0;hasOnlyOwnFiles =selectionCount > 0 && selected.ownCount === selectionCount;}@@ -500,6 +503,7 @@ export const FileList: React.FC<FileListProps> = ({barMode: mode,isInSearchMode: modePlus === "search",collectionSummary,+ hasOwnFiles,hasOnlyOwnFiles,showAddPerson: !!showAddPersonAction,showEditLocation: !!showEditLocationAction && hasOnlyOwnFiles,diff --git a/web/apps/photos/src/components/SelectedFileOptions.tsx b/web/apps/photos/src/components/SelectedFileOptions.tsxindex b963fd3e74..f4e31004b4 100644--- a/web/apps/photos/src/components/SelectedFileOptions.tsx+++ b/web/apps/photos/src/components/SelectedFileOptions.tsx@@ -217,6 +217,7 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({barMode,isInSearchMode,collectionSummary,+ hasOwnFiles: selectedOwnFileCount > 0,hasOnlyOwnFiles,showAddPerson: !!onShowAssignPersonDialog,showEditLocation: !!onEditLocation && hasOnlyOwnFiles,diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex d884ed5a1f..f76eca7c04 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -1569,6 +1569,7 @@ const Page: React.FC = () => {const selectedOwnCount = selected.ownCount;const handleDeleteFiles = useCallback((suppressSelectionBar = false) => {+ if (selectedOwnCount === 0) return;setTrashFilesDialog({count: selectedOwnCount,onConfirm: createFileOpHandler("trash", {diff --git a/web/apps/photos/src/utils/file-actions.ts b/web/apps/photos/src/utils/file-actions.tsindex a971b08a8c..0941d84aad 100644--- a/web/apps/photos/src/utils/file-actions.ts+++ b/web/apps/photos/src/utils/file-actions.ts@@ -27,6 +27,7 @@ interface FileActionContext {barMode?: GalleryBarMode;isInSearchMode: boolean;collectionSummary: CollectionSummary | undefined;+ hasOwnFiles: boolean;hasOnlyOwnFiles: boolean;showAddPerson: boolean;showEditLocation: boolean;@@ -39,6 +40,7 @@ export function getAvailableFileActions(barMode,isInSearchMode,collectionSummary,+ hasOwnFiles,hasOnlyOwnFiles,showAddPerson,showEditLocation,@@ -60,7 +62,9 @@ export function getAvailableFileActions(insertAddPersonBeforeModifications(actions);}- return actions;+ return hasOwnFiles+ ? actions+ : actions.filter((action) => action !== "trash");}function getBaseActions(diff --git a/web/apps/photos/tests/file-actions.test.ts b/web/apps/photos/tests/file-actions.test.tsindex 9deb9e7157..d9b78812e1 100644--- a/web/apps/photos/tests/file-actions.test.ts+++ b/web/apps/photos/tests/file-actions.test.ts@@ -9,6 +9,7 @@ describe("getAvailableFileActions", () => {barMode: "hidden-albums",isInSearchMode: false,collectionSummary: undefined,+ hasOwnFiles: true,hasOnlyOwnFiles: true,showAddPerson: false,showEditLocation: false,@@ -29,6 +30,21 @@ describe("getAvailableFileActions", () => {barMode: "hidden-albums",isInSearchMode: false,collectionSummary: undefined,+ hasOwnFiles: false,+ hasOnlyOwnFiles: false,+ showAddPerson: false,+ showEditLocation: false,+ }),+ ).toEqual(["download", "addToAlbum", "unhide"]);+ });++ test("allows trashing owned files in a mixed hidden-album selection", () => {+ expect(+ getAvailableFileActions({+ barMode: "hidden-albums",+ isInSearchMode: false,+ collectionSummary: undefined,+ hasOwnFiles: true,hasOnlyOwnFiles: false,showAddPerson: false,showEditLocation: false,@@ -57,6 +73,7 @@ describe("getAvailableFileActions", () => {getAvailableFileActions({isInSearchMode: false,collectionSummary,+ hasOwnFiles: false,hasOnlyOwnFiles: false,showAddPerson: false,showEditLocation: false,