From 10ebef22d3386a83f7ab0882a149a8930c4ba2f8 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sat, 28 Oct 2023 01:38:22 -0700 Subject: [PATCH] timeline: use map for preloads Signed-off-by: Varun Patil --- src/components/Timeline.vue | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index e6fb0aa0..7cf7bb08 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -744,12 +744,7 @@ export default defineComponent({ // Store the preloads in a separate map. // This is required since otherwise the inner detail objects // do not become reactive (which happens only after assignment). - const preloads: { - [dayId: number]: { - day: IDay; - detail: IPhoto[]; - }; - } = {}; + const preloads = new Map(); let prevDay: IDay | null = null; for (const day of data) { @@ -763,10 +758,7 @@ export default defineComponent({ // Store the preloads if (day.detail) { - preloads[day.dayid] = { - day: day, - detail: day.detail, - }; + preloads.set(day.dayid, day.detail); delete day.detail; } @@ -832,8 +824,8 @@ export default defineComponent({ // Iterate the preload map // Now the inner detail objects are reactive - for (const dayId in preloads) { - this.processDay(Number(dayId), preloads[dayId].detail); + for (const dayId of preloads.keys()) { + this.processDay(dayId, preloads.get(dayId)!); } // Notify parent components about stats