From f02974045b30ed8329341c67fa5bf20c09e6f4fa Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 10 Mar 2025 15:45:13 +0530 Subject: [PATCH] Move --- .../Collections/GalleryBarAndListHeader.tsx | 2 +- .../{PhotoList/index.tsx => FileList.tsx} | 13 ++++----- web/apps/photos/src/components/PhotoFrame.tsx | 29 ++++++++++--------- .../components/pages/gallery/PreviewCard.tsx | 2 +- web/apps/photos/src/pages/gallery.tsx | 2 +- web/apps/photos/src/pages/shared-albums.tsx | 2 +- web/apps/photos/src/types/gallery/index.ts | 2 +- .../utils/publicCollectionGallery/index.ts | 2 +- .../components/{PhotoList.ts => FileList.ts} | 0 .../new/photos/components/gallery/BarImpl.tsx | 2 +- 10 files changed, 27 insertions(+), 29 deletions(-) rename web/apps/photos/src/components/{PhotoList/index.tsx => FileList.tsx} (99%) rename web/packages/new/photos/components/{PhotoList.ts => FileList.ts} (100%) diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx index 751d97ca56..119c4f7107 100644 --- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx +++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx @@ -23,7 +23,7 @@ import { import { AllAlbums } from "components/Collections/AllAlbums"; import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer"; import { CollectionShare } from "components/Collections/CollectionShare"; -import { ITEM_TYPE, TimeStampListItem } from "components/PhotoList"; +import { ITEM_TYPE, TimeStampListItem } from "components/FileList"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import { sortCollectionSummaries } from "services/collectionService"; import { SetFilesDownloadProgressAttributesCreator } from "types/gallery"; diff --git a/web/apps/photos/src/components/PhotoList/index.tsx b/web/apps/photos/src/components/FileList.tsx similarity index 99% rename from web/apps/photos/src/components/PhotoList/index.tsx rename to web/apps/photos/src/components/FileList.tsx index 6a85f02b46..2e7aebc834 100644 --- a/web/apps/photos/src/components/PhotoList/index.tsx +++ b/web/apps/photos/src/components/FileList.tsx @@ -6,7 +6,7 @@ import { IMAGE_CONTAINER_MAX_HEIGHT, IMAGE_CONTAINER_MAX_WIDTH, MIN_COLUMNS, -} from "@/new/photos/components/PhotoList"; +} from "@/new/photos/components/FileList"; import { FlexWrapper } from "@ente/shared/components/Container"; import { Box, Checkbox, Link, Typography, styled } from "@mui/material"; import type { PhotoFrameProps } from "components/PhotoFrame"; @@ -188,7 +188,7 @@ export interface FileListAnnotatedFile { timelineDateString: string; } -type Props = Pick & { +type FileListProps = Pick & { height: number; width: number; annotatedFiles: FileListAnnotatedFile[]; @@ -248,10 +248,7 @@ const PhotoListRow = React.memo( areEqual, ); -/** - * TODO: Rename me to FileList. - */ -export function PhotoList({ +export const FileList: React.FC = ({ height, width, mode, @@ -261,7 +258,7 @@ export function PhotoList({ getThumbnail, activeCollectionID, activePersonID, -}: Props) { +}) => { const galleryContext = useContext(GalleryContext); const publicCollectionGalleryContext = useContext( PublicCollectionGalleryContext, @@ -918,4 +915,4 @@ export function PhotoList({ {PhotoListRow} ); -} +}; diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx index 5d164c9ad3..e96063455f 100644 --- a/web/apps/photos/src/components/PhotoFrame.tsx +++ b/web/apps/photos/src/components/PhotoFrame.tsx @@ -23,7 +23,7 @@ import { } from "types/gallery"; import { downloadSingleFile } from "utils/file"; import { handleSelectCreator } from "utils/photoFrame"; -import { PhotoList, type FileListAnnotatedFile } from "./PhotoList"; +import { FileList, type FileListAnnotatedFile } from "./FileList"; import PreviewCard from "./pages/gallery/PreviewCard"; const Container = styled("div")` @@ -178,12 +178,14 @@ const PhotoFrame = ({ const [currentHover, setCurrentHover] = useState(null); const [isShiftKeyPressed, setIsShiftKeyPressed] = useState(false); - const annotatedFileListFiles = useMemo((): FileListAnnotatedFile[] => { - return files.map((file) => ({ - file, - timelineDateString: fileTimelineDateString(file), - })); - }, [files]); + const annotatedFiles = useMemo( + (): FileListAnnotatedFile[] => + files.map((file) => ({ + file, + timelineDateString: fileTimelineDateString(file), + })), + [files], + ); const handleThumbnailClick = useCallback((index: number) => { setCurrentIndex(index); @@ -294,17 +296,16 @@ const PhotoFrame = ({ (index - i) * direction >= 0; i += direction ) { - checked = - checked && !!selected[annotatedFileListFiles[i].file.id]; + checked = checked && !!selected[annotatedFiles[i].file.id]; } for ( let i = rangeStart; (index - i) * direction > 0; i += direction ) { - handleSelect(annotatedFileListFiles[i].file)(!checked); + handleSelect(annotatedFiles[i].file)(!checked); } - handleSelect(annotatedFileListFiles[index].file, index)(!checked); + handleSelect(annotatedFiles[index].file, index)(!checked); } }; @@ -369,7 +370,7 @@ const PhotoFrame = ({ }; */ - if (!annotatedFileListFiles.length) { + if (!files.length) { return <>; } @@ -377,13 +378,13 @@ const PhotoFrame = ({ {({ height, width }) => ( -