diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue index 2864811881484db5627916c5779654874ec1c1e1..26ed6afc74a26a6ea88228549a0752ca67dc9ded 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue @@ -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)); }, };