Skip to content

armgit / ente

Public Imported from GitHub
0

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

copy 1

Manav Rathi1bc8c44b54ec
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 5f174e89cd..91ba9de7a3 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -37,6 +37,7 @@ import {
ImageEditorOverlay,
type ImageEditorOverlayProps,
} from "@/new/photos/components/ImageEditorOverlay";
+import ContentCopyIcon from "@mui/icons-material/ContentCopy";
import DeleteIcon from "@mui/icons-material/Delete";
import EditIcon from "@mui/icons-material/Edit";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
@@ -338,8 +339,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
: undefined;
}, [onDelete, showConfirmDelete, handleMoreMenuClose]);
- // Not memoized since it depends on the frequently changing
- // `activeAnnotatedFile`.
+ // Not memoized since it uses the frequently changing `activeAnnotatedFile`.
const handleDelete = async () => {
const file = activeAnnotatedFile!.file;
await onDelete(file);
@@ -364,6 +364,11 @@ const FileViewer: React.FC<FileViewerProps> = ({
});
};
+ // Not memoized since it uses the frequently changing `activeAnnotatedFile`.
+ const handleCopyImage = () => {
+ console.log("TODO copy", activeAnnotatedFile!);
+ };
+
const handleEditImage = useMemo(() => {
return onSaveEditedImageCopy
? () => {
@@ -388,10 +393,9 @@ const FileViewer: React.FC<FileViewerProps> = ({
const handleAnnotate = useCallback(
(file: EnteFile): FileViewerFileAnnotation => {
- log.debug(() => ["viewer", { action: "annotate", file }]);
-
const fileID = file.id;
const isOwnFile = file.ownerID == user?.id;
+
const canModify =
isOwnFile && !isInTrashSection && !isInHiddenSection;
const showFavorite = canModify;
@@ -413,16 +417,30 @@ const FileViewer: React.FC<FileViewerProps> = ({
}
})();
+ const showCopyImage = (() => {
+ switch (file.metadata.fileType) {
+ case FileType.image:
+ case FileType.livePhoto:
+ return true;
+ default:
+ return false;
+ }
+ })();
+
const showMore =
- showDelete || showEditImage || showDownload == "menu";
+ showDownload == "menu" ||
+ showDelete ||
+ showCopyImage ||
+ showEditImage;
return {
fileID,
isOwnFile,
showFavorite,
+ showDownload,
showMore,
showDelete,
- showDownload,
+ showCopyImage,
showEditImage,
};
},
@@ -602,6 +620,14 @@ const FileViewer: React.FC<FileViewerProps> = ({
<DeleteIcon />
</MoreMenuItem>
)}
+ {activeAnnotatedFile?.annotation.showCopyImage && (
+ <MoreMenuItem onClick={handleCopyImage}>
+ <Typography sx={{ fontWeight: "medium" }}>
+ {/*TODO */ pt("Copy image")}
+ </Typography>
+ <ContentCopyIcon />
+ </MoreMenuItem>
+ )}
{activeAnnotatedFile?.annotation.showEditImage && (
<MoreMenuItem onClick={handleEditImage}>
<Typography sx={{ fontWeight: "medium" }}>
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 2aded83324..c8d170bfe3 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -53,14 +53,6 @@ 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.
- */
- showDelete: boolean;
/**
* Set if the download action should be shown for this file.
*
@@ -71,6 +63,18 @@ export interface FileViewerFileAnnotation {
* Note: "bar" should only be set if {@link haveUser} is also true.
*/
showDownload: "bar" | "menu" | undefined;
+ /**
+ * `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.
+ */
+ showDelete: boolean;
+ /**
+ * `true` if the copy image action should be shown for this file.
+ */
+ showCopyImage: boolean;
/**
* `true` if this is an image which can be edited, _and_ editing is
* possible, and the edit action should therefore be shown for this file.