π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
cleanup
Manav Rathi4312b024f681
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex e9f7260a64..c81da4acb5 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -66,9 +66,15 @@ export interface FileListAnnotatedFile {* The date string using with the associated {@link file} should be shown in* the timeline.*- * This for used for grouping files: all files which have the same- * {@link timelineDateString} are grouped together into a section titled- * with that {@link timelineDateString}.+ * [Note: Timeline date string]+ *+ * The timeline date string is a formatted date string under which a+ * particular file should be grouped in the gallery listing. e.g. "Today",+ * "Yesterday", "Fri, 21 Feb" etc.+ *+ * All files which have the same timelineDateString will be grouped under a+ * single section in the gallery listing, prefixed by the timelineDateString+ * itself, and a checkbox to select all files on that date.*/timelineDateString: string;}diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex 6edec88ab3..8588b921c6 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -4,7 +4,6 @@ import {FileViewer,type FileViewerProps,} from "@/gallery/components/viewer/FileViewer";-import { type RenderableSourceURLs } from "@/gallery/services/download";import type { Collection } from "@/media/collection";import { EnteFile } from "@/media/file";import { moveToTrash, TRASH_SECTION } from "@/new/photos/services/collection";@@ -25,45 +24,6 @@ import {type FileListProps,} from "./FileList";-/**- * An {@link EnteFile} augmented with various in-memory state used for- * displaying it in the photo viewer.- */-export type DisplayFile = EnteFile & {- src?: string;- srcURLs?: RenderableSourceURLs;- /**- * An object URL corresponding to the image portion, if any, associated with- * the {@link DisplayFile}.- *- * - For images, this will be the object URL of the renderable image itself.- * - For live photos, this will be the object URL of the image portion of- * the live photo.- * - For videos, this will not be defined.- */- associatedImageURL?: string | undefined;- msrc?: string;- html?: string;- w?: number;- h?: number;- title?: string;- isSourceLoaded?: boolean;- conversionFailed?: boolean;- canForceConvert?: boolean;- /**- * [Note: Timeline date string]- *- * The timeline date string is a formatted date string under which a- * particular file should be grouped in the gallery listing. e.g. "Today",- * "Yesterday", "Fri, 21 Feb" etc.- *- * All files which have the same timelineDateString will be grouped under a- * single section in the gallery listing, prefixed by the timelineDateString- * itself, and a checkbox to select all files on that date.- */- timelineDateString?: string;-};-export type FileListWithViewerProps = {/*** The list of files to show.@@ -276,7 +236,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({const Container = styled("div")`flex: 1;width: 100%;-`;/**diff --git a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsxindex 0c974ac78a..d819390f4b 100644--- a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx+++ b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx@@ -1,8 +1,7 @@import { Overlay } from "@/base/components/containers";import { formattedDateRelative } from "@/base/i18n-date";-import log from "@/base/log";import { downloadManager } from "@/gallery/services/download";-import { enteFileDeletionDate } from "@/media/file";+import { enteFileDeletionDate, type EnteFile } from "@/media/file";import { FileType } from "@/media/file-type";import { GAP_BTW_TILES } from "@/new/photos/components/FileList";import {@@ -16,14 +15,13 @@ import AlbumOutlinedIcon from "@mui/icons-material/AlbumOutlined";import FavoriteRoundedIcon from "@mui/icons-material/FavoriteRounded";import PlayCircleOutlineOutlinedIcon from "@mui/icons-material/PlayCircleOutlineOutlined";import { styled, Typography } from "@mui/material";-import type { DisplayFile } from "components/FileListWithViewer";import { GalleryContext } from "pages/gallery";-import React, { useContext, useEffect, useRef, useState } from "react";+import React, { useContext, useEffect, useState } from "react";import { shouldShowAvatar } from "utils/file";import Avatar from "./Avatar";interface PreviewCardProps {- file: DisplayFile;+ file: EnteFile;onClick: () => void;selectable: boolean;selected: boolean;@@ -216,45 +214,21 @@ export default function PreviewCard({}: PreviewCardProps) {const galleryContext = useContext(GalleryContext);- const longPressCallback = () => {- onSelect(!selected);- };-- const longPress = useLongPress(longPressCallback, 500);+ const [imageURL, setImageURL] = useState<string | undefined>(undefined);- const [imgSrc, setImgSrc] = useState<string>(file.msrc);-- const isMounted = useRef(true);+ const longPress = useLongPress(() => onSelect(!selected), 500);useEffect(() => {- return () => {- isMounted.current = false;- };- }, []);+ let didCancel = false;- useEffect(() => {- const main = async () => {- try {- if (file.msrc) {- return;- }- const url: string =- await downloadManager.renderableThumbnailURL(- file,- showPlaceholder,- );+ void downloadManager+ .renderableThumbnailURL(file, showPlaceholder)+ .then((url) => !didCancel && setImageURL(url));- if (!isMounted.current || !url) {- return;- }- setImgSrc(url);- } catch (e) {- log.error("preview card useEffect failed", e);- // no-op- }+ return () => {+ didCancel = true;};- main();- }, [showPlaceholder]);+ }, [file, showPlaceholder]);const handleClick = () => {if (selectOnClick) {@@ -263,7 +237,7 @@ export default function PreviewCard({} else {onSelect(!selected);}- } else if (file?.msrc || imgSrc) {+ } else if (imageURL) {onClick?.();}};@@ -287,7 +261,7 @@ export default function PreviewCard({key={`thumb-${file.id}}`}onClick={handleClick}onMouseEnter={handleHover}- disabled={!file?.msrc && !imgSrc}+ disabled={!imageURL}{...(selectable ? longPress : {})}>{selectable && (@@ -301,8 +275,8 @@ export default function PreviewCard({)}{file.metadata.hasStaticThumbnail ? (<StaticThumbnail fileType={file.metadata.fileType} />- ) : imgSrc ? (- <img src={imgSrc} />+ ) : imageURL ? (+ <img src={imageURL} />) : (<LoadingThumbnail />)}