From e13e9cb37b1e1ee0495279a5f547a87e52bf5f77 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sat, 28 Oct 2023 00:51:09 -0700 Subject: [PATCH] timeline: make fetchDay once explicitly Signed-off-by: Varun Patil --- src/components/Timeline.vue | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 68247ab3..47423926 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -866,6 +866,9 @@ export default defineComponent({ /** Fetch image data for one dayId */ async fetchDay(dayId: number, now = false) { + if (!now && this.loadedDays.has(dayId)) return; + + // Get head to ensure the day exists / is valid const head = this.heads[dayId]; if (!head) return; @@ -910,17 +913,13 @@ export default defineComponent({ now ||= this.fetchDayQueue.reduce((sum, dayId) => sum + this.heads[dayId]?.day?.count ?? 0, 0) > 256; // Process immediately - if (now) { - return this.fetchDayExpire(); - } + if (now) return await this.fetchDayExpire(); // Defer for aggregation - if (!this.fetchDayTimer) { - this.fetchDayTimer = window.setTimeout(() => { - this.fetchDayTimer = null; - this.fetchDayExpire(); - }, 150); - } + this.fetchDayTimer ??= window.setTimeout(() => { + this.fetchDayTimer = null; + this.fetchDayExpire(); + }, 150); }, async fetchDayExpire() {