diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx index 158277ff23..ac764bd1a4 100644 --- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx +++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx @@ -1,3 +1,4 @@ +import { UnidentifiedFaces } from "@/new/photos/components/PeopleList"; import { isMLEnabled } from "@/new/photos/services/ml"; import { EnteFile } from "@/new/photos/types/file"; import CopyButton from "@ente/shared/components/CodeBlock/CopyButton"; @@ -12,9 +13,8 @@ import TextSnippetOutlined from "@mui/icons-material/TextSnippetOutlined"; import { Box, DialogProps, Link, Stack, styled } from "@mui/material"; import { Chip } from "components/Chip"; import { EnteDrawer } from "components/EnteDrawer"; -import Titlebar from "components/Titlebar"; -import { UnidentifiedFaces } from "components/ml/PeopleList"; import LinkButton from "components/pages/gallery/LinkButton"; +import Titlebar from "components/Titlebar"; import { t } from "i18next"; import { AppContext } from "pages/_app"; import { GalleryContext } from "pages/gallery"; diff --git a/web/apps/photos/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx b/web/apps/photos/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx index 6242090dfe..56dbd305fb 100644 --- a/web/apps/photos/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx +++ b/web/apps/photos/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx @@ -1,7 +1,7 @@ +import { PeopleList } from "@/new/photos/components/PeopleList"; import { isMLEnabled } from "@/new/photos/services/ml"; import { Row } from "@ente/shared/components/Container"; import { Box, styled } from "@mui/material"; -import { PeopleList } from "components/ml/PeopleList"; import { t } from "i18next"; import { components } from "react-select"; import { Suggestion, SuggestionType } from "types/search"; diff --git a/web/apps/photos/src/components/ml/PeopleList.tsx b/web/packages/new/photos/components/PeopleList.tsx similarity index 86% rename from web/apps/photos/src/components/ml/PeopleList.tsx rename to web/packages/new/photos/components/PeopleList.tsx index 2a3da9f3b0..964f93a9f6 100644 --- a/web/apps/photos/src/components/ml/PeopleList.tsx +++ b/web/packages/new/photos/components/PeopleList.tsx @@ -10,34 +10,30 @@ import { t } from "i18next"; import React, { useEffect, useState } from "react"; export interface PeopleListProps { - people: Array; - maxRows?: number; + people: Person[]; + maxRows: number; onSelect?: (person: Person, index: number) => void; } -export const PeopleList = React.memo((props: PeopleListProps) => { +export const PeopleList: React.FC = ({ + people, + maxRows, + onSelect, +}) => { return ( - - {props.people.map((person, index) => ( + + {people.map((person, index) => ( - props.onSelect && props.onSelect(person, index) - } + clickable={!!onSelect} + onClick={() => onSelect && onSelect(person, index)} > ))} ); -}); +}; const FaceChipContainer = styled("div")` display: flex; @@ -89,7 +85,7 @@ export const UnidentifiedFaces: React.FC = ({ useEffect(() => { let didCancel = false; - (async () => { + const go = async () => { const faceIDs = await unidentifiedFaceIDs(enteFile); !didCancel && setFaceIDs(faceIDs); // Don't block for the regeneration to happen. If anything got @@ -99,7 +95,9 @@ export const UnidentifiedFaces: React.FC = ({ void regenerateFaceCropsIfNeeded(enteFile).then((r) => setDidRegen(r), ); - })(); + }; + + void go(); return () => { didCancel = true; @@ -110,7 +108,7 @@ export const UnidentifiedFaces: React.FC = ({ return ( <> - + {t("UNIDENTIFIED_FACES")} @@ -140,7 +138,7 @@ const FaceCropImageView: React.FC = ({ faceID }) => { useEffect(() => { let didCancel = false; if (faceID) { - blobCache("face-crops") + void blobCache("face-crops") .then((cache) => cache.get(faceID)) .then((data) => { if (data) { diff --git a/web/packages/new/photos/services/ml/people.ts b/web/packages/new/photos/services/ml/people.ts index 0dac096dc4..97118ea94a 100644 --- a/web/packages/new/photos/services/ml/people.ts +++ b/web/packages/new/photos/services/ml/people.ts @@ -2,7 +2,7 @@ export interface Person { id: number; name?: string; files: number[]; - displayFaceId?: string; + displayFaceId: string; } // TODO-ML(MR): Forced disable clustering. It doesn't currently work,