π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
conv
Manav Rathi30da80f058a1
diff --git a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsxindex e9bc01a1fc..ca8f740fc6 100644--- a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx+++ b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx@@ -23,15 +23,13 @@ import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlinedimport VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";import { IconButton, Tooltip, Typography } from "@mui/material";import { t } from "i18next";-import { COLLECTION_OPS_TYPE } from "utils/collection";+import { type CollectionOp } from "utils/collection";import { FILE_OPS_TYPE } from "utils/file";interface Props {- handleCollectionOps: (- opsType: COLLECTION_OPS_TYPE,- ) => (...args: any[]) => void;+ handleCollectionOp: (opsType: CollectionOp) => (...args: any[]) => void;handleFileOps: (opsType: FILE_OPS_TYPE) => (...args: any[]) => void;- showCreateCollectionModal: (opsType: COLLECTION_OPS_TYPE) => () => void;+ showCreateCollectionModal: (op: CollectionOp) => () => void;/*** Callback to open a dialog where the user can choose a collection.*@@ -78,7 +76,7 @@ interface Props {const SelectedFileOptions = ({showCreateCollectionModal,onOpenCollectionSelector,- handleCollectionOps,+ handleCollectionOp,handleFileOps,selectedCollection,count,@@ -99,10 +97,8 @@ const SelectedFileOptions = ({const addToCollection = () =>onOpenCollectionSelector({action: "add",- onSelectCollection: handleCollectionOps(COLLECTION_OPS_TYPE.ADD),- onCreateCollection: showCreateCollectionModal(- COLLECTION_OPS_TYPE.ADD,- ),+ onSelectCollection: handleCollectionOp("add"),+ onCreateCollection: showCreateCollectionModal("add"),relatedCollectionID:isInSearchMode || peopleMode ? undefined : activeCollectionID,});@@ -132,12 +128,8 @@ const SelectedFileOptions = ({const restoreHandler = () =>onOpenCollectionSelector({action: "restore",- onSelectCollection: handleCollectionOps(- COLLECTION_OPS_TYPE.RESTORE,- ),- onCreateCollection: showCreateCollectionModal(- COLLECTION_OPS_TYPE.RESTORE,- ),+ onSelectCollection: handleCollectionOp("restore"),+ onCreateCollection: showCreateCollectionModal("restore"),});const removeFromCollectionHandler = () => {@@ -150,9 +142,7 @@ const SelectedFileOptions = ({color: "primary",action: () =>- handleCollectionOps(COLLECTION_OPS_TYPE.REMOVE)(- selectedCollection,- ),+ handleCollectionOp("remove")(selectedCollection),},});} else {@@ -163,9 +153,7 @@ const SelectedFileOptions = ({text: t("yes_remove"),color: "critical",action: () =>- handleCollectionOps(COLLECTION_OPS_TYPE.REMOVE)(- selectedCollection,- ),+ handleCollectionOp("remove")(selectedCollection),},});}@@ -174,10 +162,8 @@ const SelectedFileOptions = ({const moveToCollection = () => {onOpenCollectionSelector({action: "move",- onSelectCollection: handleCollectionOps(COLLECTION_OPS_TYPE.MOVE),- onCreateCollection: showCreateCollectionModal(- COLLECTION_OPS_TYPE.MOVE,- ),+ onSelectCollection: handleCollectionOp("move"),+ onCreateCollection: showCreateCollectionModal("move"),relatedCollectionID:isInSearchMode || peopleMode ? undefined : activeCollectionID,});@@ -186,10 +172,8 @@ const SelectedFileOptions = ({const unhideToCollection = () => {onOpenCollectionSelector({action: "unhide",- onSelectCollection: handleCollectionOps(COLLECTION_OPS_TYPE.UNHIDE),- onCreateCollection: showCreateCollectionModal(- COLLECTION_OPS_TYPE.UNHIDE,- ),+ onSelectCollection: handleCollectionOp("unhide"),+ onCreateCollection: showCreateCollectionModal("unhide"),});};diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 0741bcaaba..832179bf28 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -128,9 +128,9 @@ import {SetFilesDownloadProgressAttributesCreator,} from "types/gallery";import {- COLLECTION_OPS_TYPE,getSelectedCollection,- handleCollectionOps,+ handleCollectionOp,+ type CollectionOp,} from "utils/collection";import { FILE_OPS_TYPE, getSelectedFiles, handleFileOps } from "utils/file";@@ -684,20 +684,20 @@ const Page: React.FC = () => {}, []);const collectionOpsHelper =- (ops: COLLECTION_OPS_TYPE) => async (collection: Collection) => {+ (op: CollectionOp) => async (collection: Collection) => {showLoadingBar();try {setOpenCollectionSelector(false);const selectedFiles = getSelectedFiles(selected, filteredFiles);const toProcessFiles =- ops === COLLECTION_OPS_TYPE.REMOVE+ op == "remove"? selectedFiles: selectedFiles.filter((file) => file.ownerID === user.id,);if (toProcessFiles.length > 0) {- await handleCollectionOps(- ops,+ await handleCollectionOp(+ op,collection,toProcessFiles,selected.collectionID,@@ -748,12 +748,12 @@ const Page: React.FC = () => {}};- const showCreateCollectionModal = (ops: COLLECTION_OPS_TYPE) => {+ const showCreateCollectionModal = (op: CollectionOp) => {const callback = async (collectionName: string) => {try {showLoadingBar();const collection = await createAlbum(collectionName);- await collectionOpsHelper(ops)(collection);+ await collectionOpsHelper(op)(collection);} catch (e) {onGenericError(e);} finally {@@ -976,7 +976,7 @@ const Page: React.FC = () => {>{showSelectionBar ? (<SelectedFileOptions- handleCollectionOps={collectionOpsHelper}+ handleCollectionOp={collectionOpsHelper}handleFileOps={fileOpsHelper}showCreateCollectionModal={showCreateCollectionModaldiff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.tsindex c60f45db68..4787332ce5 100644--- a/web/apps/photos/src/utils/collection.ts+++ b/web/apps/photos/src/utils/collection.ts@@ -45,41 +45,34 @@ import {} from "types/gallery";import { downloadFilesWithProgress } from "utils/file";-export enum COLLECTION_OPS_TYPE {- ADD,- MOVE,- REMOVE,- RESTORE,- UNHIDE,-}-export async function handleCollectionOps(- type: COLLECTION_OPS_TYPE,+export type CollectionOp = "add" | "move" | "remove" | "restore" | "unhide";++export async function handleCollectionOp(+ op: CollectionOp,collection: Collection,selectedFiles: EnteFile[],selectedCollectionID: number,) {- switch (type) {- case COLLECTION_OPS_TYPE.ADD:+ switch (op) {+ case "add":await addToCollection(collection, selectedFiles);break;- case COLLECTION_OPS_TYPE.MOVE:+ case "move":await moveToCollection(selectedCollectionID,collection,selectedFiles,);break;- case COLLECTION_OPS_TYPE.REMOVE:+ case "remove":await removeFromCollection(collection.id, selectedFiles);break;- case COLLECTION_OPS_TYPE.RESTORE:+ case "restore":await restoreToCollection(collection, selectedFiles);break;- case COLLECTION_OPS_TYPE.UNHIDE:+ case "unhide":await unhideToCollection(collection, selectedFiles);break;- default:- throw Error("Invalid collection operation");}}