π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prioritize shared collection file actions
Neeraj Guptac5363cfee395
diff --git a/web/apps/photos/tests/file-actions.test.ts b/web/apps/photos/tests/file-actions.test.tsnew file mode 100644index 0000000000..7c42ec5043--- /dev/null+++ b/web/apps/photos/tests/file-actions.test.ts@@ -0,0 +1,33 @@+import type { CollectionSummary } from "ente-new/photos/services/collection-summary";+import { getAvailableFileActions } from "ente-new/photos/utils/file-actions";+import { describe, expect, test } from "vitest";++describe("getAvailableFileActions", () => {+ test("uses shared actions for an incoming uncategorized collection", () => {+ const collectionSummary: CollectionSummary = {+ id: 1,+ type: "sharedIncoming",+ attributes: new Set([+ "sharedIncoming",+ "sharedIncomingAdmin",+ "uncategorized",+ ]),+ name: "Shared uncategorized",+ latestFile: undefined,+ coverFile: undefined,+ fileCount: 1,+ updationTime: undefined,+ sortPriority: 0,+ };++ expect(+ getAvailableFileActions({+ isInSearchMode: false,+ collectionSummary,+ hasOnlyOwnFiles: false,+ showAddPerson: false,+ showEditLocation: false,+ }),+ ).toEqual(["favorite", "download", "addToAlbum", "removeFromAlbum"]);+ });+});diff --git a/web/packages/new/photos/utils/file-actions.ts b/web/packages/new/photos/utils/file-actions.tsindex a15a43addd..20676c58fb 100644--- a/web/packages/new/photos/utils/file-actions.ts+++ b/web/packages/new/photos/utils/file-actions.ts@@ -143,16 +143,8 @@ function getBaseActions(return ["restore", "deletePermanently"];}- // Uncategorized actions- if (collectionSummary?.attributes.has("uncategorized")) {- const actions: FileContextAction[] = ["download"];- if (hasOnlyOwnFiles) {- actions.push("moveToAlbum", "trash");- }- return actions;- }-- // Shared incoming actions+ // Incoming summaries also retain their underlying collection type,+ // so shared actions must take precedence over type-specific actions.if (collectionSummary?.attributes.has("sharedIncoming")) {const actions: FileContextAction[] = ["favorite",@@ -168,6 +160,15 @@ function getBaseActions(return actions;}+ // Uncategorized actions+ if (collectionSummary?.attributes.has("uncategorized")) {+ const actions: FileContextAction[] = ["download"];+ if (hasOnlyOwnFiles) {+ actions.push("moveToAlbum", "trash");+ }+ return actions;+ }+// Hidden albums mode actionsif (barMode === "hidden-albums") {return ["download", "unhide", "trash"];