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

Make computed gqlQueryArgs side-effect free again

Was loading while scrolling before!
parent bb903b61
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"
......@@ -105,6 +105,8 @@ export default {
knownDates: {},
docsByDay: {},
lastQuery: null,
dateStart: "",
dateEnd: "",
// Placeholder values while query isn't completed yet
groups: [],
courses: [],
......@@ -116,13 +118,12 @@ export default {
// Resets date range.
gqlQueryArgs() {
console.log('computing gqlQueryArgs');
const dateRange = this.resetDate();
return {
own: this.filterType === "all" ? false : true,
objId: this.objId ? Number(this.objId) : undefined,
objType: this.objType?.toUpperCase(),
dateStart: dateRange[0].toISODate(),
dateEnd: dateRange[1].toISODate(),
dateStart: this.dateStart,
dateEnd: this.dateEnd,
incomplete: !!this.incomplete,
};
},
......@@ -154,6 +155,10 @@ export default {
},
hash: this.$route.hash,
});
// computed should not have side effects
// but this was actually done before filters was refactored into
// its own component
this.resetDate();
}
},
},
......@@ -172,7 +177,8 @@ export default {
dateRange.forEach((ts) => this.knownDates[ts] = true);
const lastIdx = dateRange.length - 1;
// Returning a dateRange each around first & last date for the initial query
return [this.dateRange(dateRange[0])[0], this.dateRange(dateRange[lastIdx])[lastIdx]];
this.dateStart = this.dateRange(dateRange[0])[0].toISODate();
this.dateEnd = this.dateRange(dateRange[lastIdx])[lastIdx].toISODate();
},
// => {dt: [dt doc ...] ...}
groupDocsByDay(docs) {
......@@ -326,7 +332,8 @@ export default {
// scroll
},
},
mounted() {
created() {
this.resetDate();
window.addEventListener('scroll', this.debounce(this.setCurrentDay, 300));
},
};
......
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