π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fav 1
Manav Rathie87d596b4c0b
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsxindex ebbff43ad7..5bb808cce8 100644--- a/web/apps/photos/src/components/PhotoFrame.tsx+++ b/web/apps/photos/src/components/PhotoFrame.tsx@@ -554,6 +554,7 @@ const PhotoFrame = ({onTriggerSyncWithRemote={handleTriggerSyncWithRemote}onSaveEditedImageCopy={handleSaveEditedImageCopy}{...{+ favoriteFileIDs,fileCollectionIDs,allCollectionsNameByID,onSelectCollection,diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex d891c08cbe..01526a2c86 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -76,6 +76,13 @@ export type FileViewerProps = ModalVisibilityProps & {* If true then the viewer does not show controls for downloading the file.*/disableDownload?: boolean;+ /**+ * File IDs of all the files that the user has marked as a favorite.+ *+ * If this is not provided then the favorite toggle button will not be shown+ * in the file actions.+ */+ favoriteFileIDs?: Set<number>;/*** Called when there was some update performed within the file viewer that* necessitates us to sync with remote again to fetch the latest updates.@@ -119,6 +126,7 @@ const FileViewer: React.FC<FileViewerProps> = ({files,initialIndex,disableDownload,+ favoriteFileIDs,fileCollectionIDs,allCollectionsNameByID,onSelectCollection,@@ -162,14 +170,27 @@ const FileViewer: React.FC<FileViewerProps> = ({const handleAnnotate = useCallback((file: EnteFile) => {+ log.debug(() => ["viewer", { action: "annotate", file }]);const fileID = file.id;const isOwnFile = file.ownerID == user?.id;- const isEditableImage = fileIsEditableImage(file);- return { fileID, isOwnFile, isEditableImage };+ const isFavorite = favoriteFileIDs?.has(file.id);+ const isEditableImage = onSaveEditedImageCopy+ ? fileIsEditableImage(file)+ : undefined;+ return { fileID, isOwnFile, isFavorite, isEditableImage };},- [user],+ [user, favoriteFileIDs, onSaveEditedImageCopy],);+ const handleToggleFavorite = useMemo(() => {+ return favoriteFileIDs+ ? (annotatedFile: FileViewerAnnotatedFile) => {+ setActiveAnnotatedFile(annotatedFile);+ console.log("handleToggleFavorite", annotatedFile);+ }+ : undefined;+ }, [favoriteFileIDs]);+const handleViewInfo = useCallback((annotatedFile: FileViewerAnnotatedFile) => {setActiveAnnotatedFile(annotatedFile);@@ -208,7 +229,6 @@ const FileViewer: React.FC<FileViewerProps> = ({return onSaveEditedImageCopy? (annotatedFile: FileViewerAnnotatedFile) => {setActiveAnnotatedFile(annotatedFile);- setActiveFileExif(undefined);setOpenImageEditor(true);}: undefined;@@ -242,6 +262,7 @@ const FileViewer: React.FC<FileViewerProps> = ({disableDownload,onClose: handleClose,onAnnotate: handleAnnotate,+ onToggleFavorite: handleToggleFavorite,onViewInfo: handleViewInfo,onEditImage: handleEditImage,});diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 0e53b70492..a40458c5f2 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -1,11 +1,11 @@/* eslint-disable */// @ts-nocheck+import { pt } from "@/base/i18n";import log from "@/base/log";import type { EnteFile } from "@/media/file";import { FileType } from "@/media/file-type";import { t } from "i18next";-import { pt } from "@/base/i18n";import {forgetExif,forgetExifForItemData,@@ -35,6 +35,40 @@ if (process.env.NEXT_PUBLIC_ENTE_WIP_PS5) {PhotoSwipe = require("./ps5/dist/photoswipe.esm.js").default;}+/**+ * Derived data for a file that is needed to display the file viewer controls+ * etc associated with the file.+ *+ * This is recomputed on-demand each time the slide changes.+ */+export interface FileViewerFileAnnotation {+ /**+ * The id of the file whose annotation this is.+ */+ fileID: number;+ /**+ * `true` if this file is owned by the logged in user (if any).+ */+ isOwnFile: boolean;+ /**+ * `true` if this file has been marked as a favorite by the user.+ *+ * It will not be provided if favorite functionality is not available.+ *+ * Otherwise it determines the toggle state of the toggle favorite button.+ */+ isFavorite?: boolean;+ /**+ * `true` if this is an image which can be edited.+ *+ * It will not be provided if editing is not available.+ *+ * Otherwise the edit button is shown when this is true. See also the+ * {@link onEditImage} option for {@link FileViewerPhotoSwipe} constructor.+ */+ isEditableImage?: boolean;+}+type FileViewerPhotoSwipeOptions = {/*** Called when the file viewer is closed.@@ -45,6 +79,15 @@ type FileViewerPhotoSwipeOptions = {* that is about to be displayed.*/onAnnotate: (file: EnteFile) => FileViewerFileAnnotation;+ /**+ * Called when the user activates the toggle favorite action on a file.+ *+ * If this callback is not provided, then the toggle favorite button is not+ * shown. If this callback is provided, then the current toggle state of the+ * favorite button is determined by the {@link isFavorite} property of+ * {@link FileViewerFileAnnotation} for the file.+ */+ onToggleFavorite?: (annotatedFile: FileViewerAnnotatedFile) => void;/*** Called when the user activates the info action on a file.*/@@ -60,30 +103,6 @@ type FileViewerPhotoSwipeOptions = {onEditImage?: (annotatedFile: FileViewerAnnotatedFile) => void;} & Pick<FileViewerProps, "files" | "initialIndex" | "disableDownload">;-/**- * Derived data for a file that is needed to display the file viewer controls- * etc associated with the file.- *- * This is recomputed on-demand each time the slide changes.- */-export interface FileViewerFileAnnotation {- /**- * The id of the file whose annotation this is.- */- fileID: number;- /**- * `true` if this file is owned by the logged in user (if any).- */- isOwnFile: boolean;- /**- * `true` if this is an image which can be edited.- *- * The edit button is shown when this is true. See also the- * {@link onEditImage} option for {@link FileViewerPhotoSwipe} constructor.- */- isEditableImage: boolean;-}-/*** A file and its annotation, in a nice cosy box.*/@@ -159,6 +178,7 @@ export class FileViewerPhotoSwipe {disableDownload,onClose,onAnnotate,+ onToggleFavorite,onViewInfo,onEditImage,}: FileViewerPhotoSwipeOptions) {@@ -416,14 +436,26 @@ export class FileViewerPhotoSwipe {});},});- pswp.ui.registerElement({- name: "info",- title: t("info"),- order: 16,- isButton: true,- html: createPSRegisterElementIconHTML("info"),- onClick: withCurrentAnnotatedFile(onViewInfo),- });++ if (onToggleFavorite) {+ pswp.ui.registerElement({+ name: "favorite",+ title: t("favorite"),+ order: 15,+ isButton: true,+ html: createPSRegisterElementIconHTML("favorite"),+ onClick: withCurrentAnnotatedFile(onToggleFavorite),+ onInit: (buttonElement, pswp) => {+ // TODO:+ // pswp.on("change", () =>+ // buttonElement.classList.toggle(+ // "pswp--ui-visible",+ // currentFileAnnotation().isFavorite,+ // ),+ // );+ },+ });+ }if (onEditImage) {pswp.ui.registerElement({@@ -431,21 +463,29 @@ export class FileViewerPhotoSwipe {// TODO(PS):// title: t("edit_image"),title: pt("Edit image"),- order: 15,+ order: 16,isButton: true,html: createPSRegisterElementIconHTML("edit"),onClick: withCurrentAnnotatedFile(onEditImage),onInit: (buttonElement, pswp) => {- pswp.on("change", () => {- const { annotation } = currentAnnotatedFile();+ pswp.on("change", () =>buttonElement.classList.toggle("pswp--ui-visible",- annotation.isEditableImage,- );- });+ currentFileAnnotation().isEditableImage,+ ),+ );},});}++ pswp.ui.registerElement({+ name: "info",+ title: t("info"),+ order: 17,+ isButton: true,+ html: createPSRegisterElementIconHTML("info"),+ onClick: withCurrentAnnotatedFile(onViewInfo),+ });});// Modify the default UI elements.