π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
del 2
Manav Rathib363e3663f2b
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsxindex c779b8412d..c6589fedc3 100644--- a/web/apps/photos/src/components/PhotoFrame.tsx+++ b/web/apps/photos/src/components/PhotoFrame.tsx@@ -14,7 +14,7 @@ import { EnteFile } from "@/media/file";import { FileType } from "@/media/file-type";import { FileViewer } from "@/new/photos/components/FileViewerComponents";import type { GalleryBarMode } from "@/new/photos/components/gallery/reducer";-import { TRASH_SECTION } from "@/new/photos/services/collection";+import { moveToTrash, TRASH_SECTION } from "@/new/photos/services/collection";import { styled } from "@mui/material";import { PhotoViewer } from "components/PhotoViewer";import { t } from "i18next";@@ -271,7 +271,7 @@ const PhotoFrame = ({);const handleToggleFavorite = useMemo(() => {- return favoriteFileIDs+ return favoriteFileIDs && onMarkUnsyncedFavoriteUpdate? async (file: EnteFile) => {const isFavorite = favoriteFileIDs!.has(file.id);await (isFavorite ? removeFromFavorites : addToFavorites)(@@ -283,6 +283,15 @@ const PhotoFrame = ({: undefined;}, [favoriteFileIDs, onMarkUnsyncedFavoriteUpdate]);+ const handleDelete = useMemo(() => {+ return onMarkTempDeleted+ ? async (file: EnteFile) => {+ await moveToTrash([file]);+ onMarkTempDeleted?.([file]);+ }+ : undefined;+ }, [favoriteFileIDs, onMarkTempDeleted]);+const handleSaveEditedImageCopy = useCallback((editedFile: File, collection: Collection, enteFile: EnteFile) => {uploadManager.prepareForNewUpload();@@ -575,6 +584,7 @@ const PhotoFrame = ({isInTrashSection={activeCollectionID === TRASH_SECTION}onTriggerSyncWithRemote={handleTriggerSyncWithRemote}onToggleFavorite={handleToggleFavorite}+ onDelete={handleDelete}onSaveEditedImageCopy={handleSaveEditedImageCopy}{...{favoriteFileIDs,diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 9b1c5dc135..cc431e902b 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -136,7 +136,7 @@ export type FileViewerProps = ModalVisibilityProps & {* If this is not provided then the delete button will not be shown* in the file actions.*/- onDeleteFile?: (file: EnteFile) => Promise<void>;+ onDelete?: (file: EnteFile) => Promise<void>;/*** Called when the user edits an image in the image editor and asks us to* save their edits as a copy.@@ -172,7 +172,7 @@ const FileViewer: React.FC<FileViewerProps> = ({allCollectionsNameByID,onTriggerSyncWithRemote,onToggleFavorite,- onDeleteFile,+ onDelete,onSelectCollection,onSelectPerson,onSaveEditedImageCopy,@@ -222,10 +222,8 @@ const FileViewer: React.FC<FileViewerProps> = ({const [moreMenuAnchorEl, setMoreMenuAnchorEl] =useState<HTMLElement | null>(null);const [openImageEditor, setOpenImageEditor] = useState(false);- const {- show: showConfirmDeleteFile,- props: confirmDeleteFileVisibilityProps,- } = useModalVisibility();+ const { show: showConfirmDelete, props: confirmDeleteVisibilityProps } =+ useModalVisibility();// If `true`, then we need to trigger a sync with remote when we close.const [, setNeedsSync] = useState(false);@@ -276,24 +274,24 @@ const FileViewer: React.FC<FileViewerProps> = ({});}, []);- const [handleConfirmDeleteFile, handleDeleteFile] = useMemo(() => {- const onConfirm = onDeleteFile+ const handleConfirmDelete = useMemo(() => {+ return onDelete? () => {handleMoreMenuClose();- showConfirmDeleteFile();+ showConfirmDelete();}: undefined;- return [onConfirm, onDeleteFile];- }, [onDeleteFile, showConfirmDeleteFile, handleMoreMenuClose]);-- // const handleDeleteFile = async () => {- // const file = fileToDelete!;- // await moveToTrash([file]);- // onMarkTempDeleted?.([file]);- // updateItems(items.filter((item) => item.id !== file.id));- // setFileToDelete(undefined);- // needUpdate.current = true;- // };+ }, [onDelete, showConfirmDelete, handleMoreMenuClose]);++ // Not memoized since it depends on the frequently changing+ // `activeAnnotatedFile`.+ const handleDelete = async () => {+ const file = activeAnnotatedFile!.file;+ await onDelete(file);+ // TODO(PS): Update the viewer+ // updateItems(items.filter((item) => item.id !== file.id));+ handleNeedsRemoteSync();+ };const handleEditImage = useMemo(() => {return onSaveEditedImageCopy@@ -327,14 +325,16 @@ const FileViewer: React.FC<FileViewerProps> = ({isOwnFile && !isInTrashSection && !isInHiddenSection;const showFavorite = canModify;const showDelete =- !!handleConfirmDeleteFile && isOwnFile && !isInTrashSection;+ !!handleConfirmDelete && isOwnFile && !isInTrashSection;const showEditImage =!!handleEditImage && canModify && fileIsEditableImage(file);+ const showMore = showDelete || showEditImage;return {fileID,isOwnFile,showFavorite,+ showMore,showDelete,showEditImage,};@@ -344,7 +344,7 @@ const FileViewer: React.FC<FileViewerProps> = ({isInTrashSection,isInHiddenSection,handleEditImage,- handleConfirmDeleteFile,+ handleConfirmDelete,],);@@ -473,7 +473,7 @@ const FileViewer: React.FC<FileViewerProps> = ({}}>{activeAnnotatedFile?.annotation.showDelete && (- <MoreMenuItem onClick={showConfirmDeleteFile}>+ <MoreMenuItem onClick={showConfirmDelete}><Typography sx={{ fontWeight: "medium" }}>{/*TODO */ t("delete")}</Typography>@@ -490,12 +490,10 @@ const FileViewer: React.FC<FileViewerProps> = ({)}</MoreMenu>{/* TODO(PS): Fix imports */}- {handleDeleteFile && (- <ConfirmDeleteFileDialog- {...confirmDeleteFileVisibilityProps}- onConfirm={handleDeleteFile}- />- )}+ <ConfirmDeleteFileDialog+ {...confirmDeleteVisibilityProps}+ onConfirm={handleDelete}+ /><ImageEditorOverlayopen={openImageEditor}onClose={handleImageEditorClose}diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 8f12f9a403..70aba66c5f 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -53,6 +53,10 @@ export interface FileViewerFileAnnotation {* `true` if the toggle favorite action should be shown for this file.*/showFavorite: boolean;+ /**+ * `true` if the more menu action should be shown for this file.+ */+ showMore: boolean;/*** `true` if the delete action should be shown for this file.*/@@ -607,7 +611,7 @@ export class FileViewerPhotoSwipe {pswp.on("change", () =>showIf(buttonElement,- !!currentFileAnnotation().isEditableImage,+ !!currentFileAnnotation().showMore,),);},