Skip to content

armgit / ente

Public Imported from GitHub
0

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

wip checkpoint

Manav Rathi7a60b1e15ebc
diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
index 20157caab7..a8c5957ba9 100644
--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
@@ -16,13 +16,14 @@ import { UnidentifiedFaces } from "@/new/photos/components/PeopleList";
import { PhotoDateTimePicker } from "@/new/photos/components/PhotoDateTimePicker";
import { photoSwipeZIndex } from "@/new/photos/components/PhotoViewer";
import { tagNumericValue, type RawExifTags } from "@/new/photos/services/exif";
-import { isMLEnabled } from "@/new/photos/services/ml";
+import { annotatedFaceIDsForFile, isMLEnabled } from "@/new/photos/services/ml";
import { EnteFile } from "@/new/photos/types/file";
import { formattedByteSize } from "@/new/photos/utils/units";
import CopyButton from "@ente/shared/components/CodeBlock/CopyButton";
import { FlexWrapper } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
import { getPublicMagicMetadataSync } from "@ente/shared/file-metadata";
+import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded";
import { formatDate, formatTime } from "@ente/shared/time/format";
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
import CameraOutlined from "@mui/icons-material/CameraOutlined";
@@ -106,6 +107,23 @@ export const FileInfo: React.FC<FileInfoProps> = ({
return exif?.parsed?.location;
}, [file, exif]);
+ const [annotatedPeopleFaceIDs, otherFaceIDs] =
+ useMemoSingleThreaded(async () => {
+ if (!file) return [[], []];
+ const annotatedFaceIDs = await annotatedFaceIDsForFile(file);
+ return annotatedFaceIDs.reduce(
+ ([people, other], item) => {
+ if (item[1]) {
+ people.push(item);
+ } else {
+ other.push(item[0]);
+ }
+ return [people, other];
+ },
+ [[], []],
+ );
+ }, [file]);
+
useEffect(() => {
setExifInfo(parseExifInfo(exif));
}, [exif]);
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index 9330cf1e4c..70d6762349 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -599,7 +599,7 @@ export const clipMatches = (
* ID of the face, and the personID is the id of the corresponding person that
* this face is associated to (if any).
*/
-export const peopleIDsAndOtherFaceIDsInFile = async (
+export const annotatedFaceIDsForFile = async (
enteFile: EnteFile,
): Promise<[string, string | undefined][]> => {
const index = await getFaceIndex(enteFile.id);