This commit is contained in:
Manav Rathi
2024-05-30 11:30:23 +05:30
parent 35090a6cdd
commit c3f6ecbf6a
2 changed files with 18 additions and 34 deletions

View File

@@ -96,8 +96,6 @@ export function FileInfo({
const [parsedExifData, setParsedExifData] = useState<Record<string, any>>();
const [showExif, setShowExif] = useState(false);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [updateMLDataIndex, setUpdateMLDataIndex] = useState(0);
const openExif = () => setShowExif(true);
const closeExif = () => setShowExif(false);
@@ -332,14 +330,8 @@ export function FileInfo({
{appContext.mlSearchEnabled && (
<>
{/* <PhotoPeopleList
file={file}
updateMLDataIndex={updateMLDataIndex}
/> */}
<UnidentifiedFaces
file={file}
updateMLDataIndex={updateMLDataIndex}
/>
{/* <PhotoPeopleList file={file} /> */}
<UnidentifiedFaces file={file} />
</>
)}
</Stack>

View File

@@ -66,35 +66,29 @@ export const PeopleList = React.memo((props: PeopleListProps) => {
export interface PhotoPeopleListProps extends PeopleListPropsBase {
file: EnteFile;
updateMLDataIndex: number;
}
export function PhotoPeopleList() {
return <></>;
}
export function UnidentifiedFaces(props: {
file: EnteFile;
updateMLDataIndex: number;
}) {
export function UnidentifiedFaces({ file }: { file: EnteFile }) {
const [faces, setFaces] = useState<{ id: string }[]>([]);
useEffect(() => {
let didCancel = false;
async function updateFaceImages() {
const faces = await getUnidentifiedFaces(props.file);
(async () => {
const faces = await unidentifiedFaceIDs(file);
!didCancel && setFaces(faces);
}
updateFaceImages();
})();
return () => {
didCancel = true;
};
}, [props.file, props.updateMLDataIndex]);
}, [file]);
if (!faces || faces.length === 0) return <></>;
if (faces.length == 0) return <></>;
return (
<>
@@ -102,12 +96,11 @@ export function UnidentifiedFaces(props: {
<Legend>{t("UNIDENTIFIED_FACES")}</Legend>
</div>
<FaceChipContainer>
{faces &&
faces.map((face, index) => (
<FaceChip key={index}>
<FaceCropImageView faceID={face.id} />
</FaceChip>
))}
{faces.map((face) => (
<FaceChip key={face.id}>
<FaceCropImageView faceID={face.id} />
</FaceChip>
))}
</FaceChipContainer>
</>
);
@@ -151,10 +144,9 @@ const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({ faceID }) => {
);
};
async function getUnidentifiedFaces(file: EnteFile): Promise<{ id: string }[]> {
const unidentifiedFaceIDs = async (
file: EnteFile,
): Promise<{ id: string }[]> => {
const mlFileData = await mlIDbStorage.getFile(file.id);
return mlFileData?.faces?.filter(
(f) => f.personId === null || f.personId === undefined,
);
}
return mlFileData?.faces;
};