|
@@ -61,8 +61,8 @@ export const PeopleList = React.memo((props: PeopleListProps) => {
|
|
}
|
|
}
|
|
>
|
|
>
|
|
<FaceCropImageView
|
|
<FaceCropImageView
|
|
- url={person.displayImageUrl}
|
|
|
|
faceId={person.displayFaceId}
|
|
faceId={person.displayFaceId}
|
|
|
|
+ cacheKey={person.faceCropCacheKey}
|
|
/>
|
|
/>
|
|
</FaceChip>
|
|
</FaceChip>
|
|
))}
|
|
))}
|
|
@@ -141,7 +141,7 @@ export function UnidentifiedFaces(props: {
|
|
<FaceChip key={index}>
|
|
<FaceChip key={index}>
|
|
<FaceCropImageView
|
|
<FaceCropImageView
|
|
faceId={face.id}
|
|
faceId={face.id}
|
|
- url={face.crop?.imageUrl}
|
|
|
|
|
|
+ cacheKey={face.crop?.cacheKey}
|
|
/>
|
|
/>
|
|
</FaceChip>
|
|
</FaceChip>
|
|
))}
|
|
))}
|
|
@@ -151,13 +151,13 @@ export function UnidentifiedFaces(props: {
|
|
}
|
|
}
|
|
|
|
|
|
interface FaceCropImageViewProps {
|
|
interface FaceCropImageViewProps {
|
|
- url: string;
|
|
|
|
faceId: string;
|
|
faceId: string;
|
|
|
|
+ cacheKey?: string;
|
|
}
|
|
}
|
|
|
|
|
|
const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({
|
|
const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({
|
|
- url,
|
|
|
|
faceId,
|
|
faceId,
|
|
|
|
+ cacheKey,
|
|
}) => {
|
|
}) => {
|
|
const [objectURL, setObjectURL] = useState<string | undefined>();
|
|
const [objectURL, setObjectURL] = useState<string | undefined>();
|
|
|
|
|
|
@@ -165,22 +165,18 @@ const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({
|
|
let didCancel = false;
|
|
let didCancel = false;
|
|
|
|
|
|
async function loadImage() {
|
|
async function loadImage() {
|
|
- let blob: Blob;
|
|
|
|
- if (!url) {
|
|
|
|
- blob = undefined;
|
|
|
|
- } else {
|
|
|
|
- blob = await cachedOrNew("face-crops", url, async () => {
|
|
|
|
- const user = await ensureLocalUser();
|
|
|
|
- return machineLearningService.regenerateFaceCrop(
|
|
|
|
- user.token,
|
|
|
|
- user.id,
|
|
|
|
- faceId,
|
|
|
|
- );
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (didCancel) return;
|
|
|
|
- setObjectURL(blob ? URL.createObjectURL(blob) : undefined);
|
|
|
|
|
|
+ const blob = cacheKey
|
|
|
|
+ ? await cachedOrNew("face-crops", cacheKey, async () => {
|
|
|
|
+ const user = await ensureLocalUser();
|
|
|
|
+ return machineLearningService.regenerateFaceCrop(
|
|
|
|
+ user.token,
|
|
|
|
+ user.id,
|
|
|
|
+ faceId,
|
|
|
|
+ );
|
|
|
|
+ })
|
|
|
|
+ : undefined;
|
|
|
|
+ if (!didCancel)
|
|
|
|
+ setObjectURL(blob ? URL.createObjectURL(blob) : undefined);
|
|
}
|
|
}
|
|
|
|
|
|
loadImage();
|
|
loadImage();
|
|
@@ -189,7 +185,7 @@ const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({
|
|
didCancel = true;
|
|
didCancel = true;
|
|
if (objectURL) URL.revokeObjectURL(objectURL);
|
|
if (objectURL) URL.revokeObjectURL(objectURL);
|
|
};
|
|
};
|
|
- }, [url, faceId]);
|
|
|
|
|
|
+ }, [faceId, cacheKey]);
|
|
|
|
|
|
return objectURL ? (
|
|
return objectURL ? (
|
|
<img src={objectURL} />
|
|
<img src={objectURL} />
|