Handle async updates in PeopleList
This commit is contained in:
parent
1d41644ac8
commit
7bfddfedce
|
@ -55,14 +55,19 @@ export interface PhotoPeopleListProps extends PeopleListPropsBase {
|
||||||
export function PhotoPeopleList(props: PhotoPeopleListProps) {
|
export function PhotoPeopleList(props: PhotoPeopleListProps) {
|
||||||
const [people, setPeople] = useState<Array<Person>>([]);
|
const [people, setPeople] = useState<Array<Person>>([]);
|
||||||
|
|
||||||
const updateFaceImages = async () => {
|
|
||||||
const people = await getPeopleList(props.file);
|
|
||||||
setPeople(people);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// TODO: handle multiple async updates
|
let didCancel = false;
|
||||||
|
|
||||||
|
async function updateFaceImages() {
|
||||||
|
const people = await getPeopleList(props.file);
|
||||||
|
!didCancel && setPeople(people);
|
||||||
|
}
|
||||||
|
|
||||||
updateFaceImages();
|
updateFaceImages();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
didCancel = true;
|
||||||
|
};
|
||||||
}, [props.file]);
|
}, [props.file]);
|
||||||
|
|
||||||
return <PeopleList people={people} onSelect={props.onSelect}></PeopleList>;
|
return <PeopleList people={people} onSelect={props.onSelect}></PeopleList>;
|
||||||
|
@ -76,20 +81,22 @@ export function AllPeopleList(props: AllPeopleListProps) {
|
||||||
const [people, setPeople] = useState<Array<Person>>([]);
|
const [people, setPeople] = useState<Array<Person>>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// TODO: handle multiple async updates
|
let didCancel = false;
|
||||||
|
|
||||||
async function updateFaceImages() {
|
async function updateFaceImages() {
|
||||||
let people = await getAllPeople();
|
let people = await getAllPeople();
|
||||||
if (props.limit) {
|
if (props.limit) {
|
||||||
people = people.slice(0, props.limit);
|
people = people.slice(0, props.limit);
|
||||||
}
|
}
|
||||||
setPeople(people);
|
!didCancel && setPeople(people);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFaceImages();
|
updateFaceImages();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
setPeople([]);
|
didCancel = true;
|
||||||
};
|
};
|
||||||
}, [props]);
|
}, [props.limit]);
|
||||||
|
|
||||||
return <PeopleList people={people} onSelect={props.onSelect}></PeopleList>;
|
return <PeopleList people={people} onSelect={props.onSelect}></PeopleList>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,8 +229,8 @@ export function findFirstIfSorted<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
||||||
syncIntervalSec: 5, // 300
|
syncIntervalSec: 5, // 20
|
||||||
batchSize: 5, // 200
|
batchSize: 200,
|
||||||
faceDetection: {
|
faceDetection: {
|
||||||
method: {
|
method: {
|
||||||
value: 'BlazeFace',
|
value: 'BlazeFace',
|
||||||
|
|
Loading…
Reference in a new issue