timeline: use map for preloads

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/900/head
Varun Patil 2023-10-28 01:38:22 -07:00
parent a151d9cbd4
commit 10ebef22d3
1 changed files with 4 additions and 12 deletions

View File

@ -744,12 +744,7 @@ export default defineComponent({
// Store the preloads in a separate map. // Store the preloads in a separate map.
// This is required since otherwise the inner detail objects // This is required since otherwise the inner detail objects
// do not become reactive (which happens only after assignment). // do not become reactive (which happens only after assignment).
const preloads: { const preloads = new Map<number, IPhoto[]>();
[dayId: number]: {
day: IDay;
detail: IPhoto[];
};
} = {};
let prevDay: IDay | null = null; let prevDay: IDay | null = null;
for (const day of data) { for (const day of data) {
@ -763,10 +758,7 @@ export default defineComponent({
// Store the preloads // Store the preloads
if (day.detail) { if (day.detail) {
preloads[day.dayid] = { preloads.set(day.dayid, day.detail);
day: day,
detail: day.detail,
};
delete day.detail; delete day.detail;
} }
@ -832,8 +824,8 @@ export default defineComponent({
// Iterate the preload map // Iterate the preload map
// Now the inner detail objects are reactive // Now the inner detail objects are reactive
for (const dayId in preloads) { for (const dayId of preloads.keys()) {
this.processDay(Number(dayId), preloads[dayId].detail); this.processDay(dayId, preloads.get(dayId)!);
} }
// Notify parent components about stats // Notify parent components about stats