Use set for loadedDays

pull/37/head
Varun Patil 2022-09-12 02:02:45 -07:00
parent 5711d18314
commit f16e95654c
1 changed files with 9 additions and 12 deletions

View File

@ -167,7 +167,9 @@ export default {
/** Is mobile layout */ /** Is mobile layout */
isMobile: false, isMobile: false,
/** List of selected file ids */ /** Set of dayIds for which images loaded */
loadedDays: new Set(),
/** Set of selected file ids */
selection: new Set(), selection: new Set(),
/** State for request cancellations */ /** State for request cancellations */
@ -211,6 +213,7 @@ export default {
this.currentEnd = 0; this.currentEnd = 0;
this.timelineTicks = []; this.timelineTicks = [];
this.state = Math.random(); this.state = Math.random();
this.loadedDays.clear();
}, },
/** Do resize after some time */ /** Do resize after some time */
@ -376,15 +379,12 @@ export default {
// Fetch all visible days // Fetch all visible days
for (let i = startIndex; i <= endIndex; i++) { for (let i = startIndex; i <= endIndex; i++) {
let item = this.list[i]; let item = this.list[i];
if (!item) { if (!item || this.loadedDays.has(item.dayId)) {
continue; continue;
} }
let head = this.heads[item.dayId]; this.loadedDays.add(item.dayId);
if (head && !head.loadedImages) { this.fetchDay(item.dayId);
head.loadedImages = true;
this.fetchDay(item.dayId);
}
} }
}, },
@ -454,7 +454,6 @@ export default {
name: dateStr, name: dateStr,
size: 40, size: 40,
head: true, head: true,
loadedImages: false,
dayId: day.dayid, dayId: day.dayid,
day: day, day: day,
}; };
@ -504,8 +503,7 @@ export default {
} }
// Do this in advance to prevent duplicate requests // Do this in advance to prevent duplicate requests
const head = this.heads[dayId]; this.loadedDays.add(dayId);
head.loadedImages = true;
try { try {
const startState = this.state; const startState = this.state;
@ -519,7 +517,6 @@ export default {
this.processDay(day, true); this.processDay(day, true);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
head.loadedImages = false;
} }
}, },
@ -585,7 +582,7 @@ export default {
const data = day.detail; const data = day.detail;
const head = this.heads[dayId]; const head = this.heads[dayId];
head.loadedImages = true; this.loadedDays.add(dayId);
// Reset rows including placeholders // Reset rows including placeholders
if (head.day?.rows) { if (head.day?.rows) {