Skip to content
Snippets Groups Projects
Commit 35753429 authored by permcu's avatar permcu
Browse files

Remove render loop caused by docsByDay

-> no more docsByDay state in component
parent d29e1f6d
No related branches found
No related tags found
2 merge requests!355Implement infinite scrolling and by date navigation for coursebook,!350Resolve "Add simple course book list"
...@@ -182,7 +182,7 @@ export default { ...@@ -182,7 +182,7 @@ export default {
}, },
groupDocsByDay(docs) { groupDocsByDay(docs) {
// => {dt: [dt doc ...] ...} // => {dt: [dt doc ...] ...}
this.docsByDay = docs.reduce((byDay, doc) => { const docsByDay = docs.reduce((byDay, doc) => {
// This works with dummy. Does actual doc have dateStart instead? // This works with dummy. Does actual doc have dateStart instead?
const day = DateTime.fromISO(doc.datetimeStart).startOf("day"); const day = DateTime.fromISO(doc.datetimeStart).startOf("day");
byDay[day] ??= [day]; byDay[day] ??= [day];
...@@ -190,9 +190,9 @@ export default { ...@@ -190,9 +190,9 @@ export default {
return byDay; return byDay;
}, {}); }, {});
// => [[dt doc ...] ...] // => [[dt doc ...] ...]
return Object.keys(this.docsByDay) return Object.keys(docsByDay)
.sort() .sort()
.map((key) => this.docsByDay[key]); .map((key) => docsByDay[key]);
// sorting is necessary since backend can send docs unordered // sorting is necessary since backend can send docs unordered
}, },
debounce(fn, delay) { debounce(fn, delay) {
...@@ -299,9 +299,10 @@ export default { ...@@ -299,9 +299,10 @@ export default {
if (!this.knownDates[date]) { if (!this.knownDates[date]) {
console.log(this.lastQuery); console.log(this.lastQuery);
console.log('unknown date', date.toISODate()); console.log('unknown date', date.toISODate());
console.log(this.knownDates);
// find missing & fetch missing range // find missing & fetch missing range
const missing = this.dateRange(date) const missing = this.dateRange(date)
.filter((ts) => !this.docsByDay[ts]); .filter((ts) => !this.knownDates[ts]);
// ask for first to last // ask for first to last
this.lastQuery.fetchMore({ this.lastQuery.fetchMore({
variables: { variables: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment