nx: debounce fresh insertion
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/807/merge
parent
f7b9940181
commit
864a240d0b
|
@ -91,10 +91,25 @@ export function mergeDay(current: IPhoto[], incoming: IPhoto[]): void {
|
||||||
* Does not update the passed objects in any way
|
* Does not update the passed objects in any way
|
||||||
* @param current Photos from day response
|
* @param current Photos from day response
|
||||||
*/
|
*/
|
||||||
export function processFreshServerDay(dayId: number, photos: IPhoto[]): void {
|
export function processFreshServerDay(this: any, dayId: number, photos: IPhoto[]): void {
|
||||||
const auids = photos.map((p) => p.auid).filter((a) => !!a) as number[];
|
const queue: Set<number> = (this.pfsdq ??= new Set<number>());
|
||||||
if (!auids.length) return;
|
|
||||||
nativex.setHasRemote(JSON.stringify(auids), true);
|
// Add to queue
|
||||||
|
for (const photo of photos) {
|
||||||
|
if (photo.auid) queue.add(photo.auid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debounce
|
||||||
|
utils.setRenewingTimeout(
|
||||||
|
this,
|
||||||
|
'pfsdq_timer',
|
||||||
|
() => {
|
||||||
|
if (!queue.size) return;
|
||||||
|
nativex.setHasRemote(JSON.stringify(Array.from(queue)), true);
|
||||||
|
queue.clear();
|
||||||
|
},
|
||||||
|
1000
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue