diff --git a/src/addon/block/myoverview/component/myoverview.ts b/src/addon/block/myoverview/component/myoverview.ts index 1638d3c4a..554b31107 100644 --- a/src/addon/block/myoverview/component/myoverview.ts +++ b/src/addon/block/myoverview/component/myoverview.ts @@ -93,10 +93,10 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement this.currentSite = this.sitesProvider.getCurrentSite(); const promises = []; - promises.push(this.currentSite.getSiteConfig('AddonBlockMyOverviewSort', this.sort).then((value) => { + promises.push(this.currentSite.getLocalSiteConfig('AddonBlockMyOverviewSort', this.sort).then((value) => { this.sort = value; })); - promises.push(this.currentSite.getSiteConfig('AddonBlockMyOverviewFilter', this.selectedFilter).then((value) => { + promises.push(this.currentSite.getLocalSiteConfig('AddonBlockMyOverviewFilter', this.selectedFilter).then((value) => { this.selectedFilter = value; })); @@ -156,17 +156,14 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement }); })); }).then((courses) => { - this.showSortFilter = courses.some((course) => { - return typeof course.lastaccess != 'undefined'; - }); + this.showSortFilter = courses.length > 0 && typeof courses[0].lastaccess != 'undefined'; this.sortCourses(courses); this.courses.filter = ''; this.showFilter = false; - this.showSelectorFilter = this.courses.past.length > 0 || this.courses.future.length > 0 || courses.some((course) => { - return typeof course.enddate != 'undefined'; - }); + this.showSelectorFilter = this.courses.past.length > 0 || this.courses.future.length > 0 || (courses.length > 0 && + typeof courses[0].enddate != 'undefined'); if (!this.showSelectorFilter) { // No selector, show all. this.selectedFilter = 'all'; @@ -255,7 +252,7 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement * The selected courses filter have changed. */ selectedChanged(): void { - this.currentSite.setSiteConfig('AddonBlockMyOverviewFilter', this.selectedFilter); + this.currentSite.setLocalSiteConfig('AddonBlockMyOverviewFilter', this.selectedFilter); this.filteredCourses = this.courses[this.selectedFilter]; } @@ -303,7 +300,7 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement * The selected courses sort filter have changed. */ switchSort(): void { - this.currentSite.setSiteConfig('AddonBlockMyOverviewSort', this.sort); + this.currentSite.setLocalSiteConfig('AddonBlockMyOverviewSort', this.sort); this.sortCourses(this.courses.all); } diff --git a/src/addon/block/timeline/components/timeline/timeline.ts b/src/addon/block/timeline/components/timeline/timeline.ts index a09eba441..4aadf42cd 100644 --- a/src/addon/block/timeline/components/timeline/timeline.ts +++ b/src/addon/block/timeline/components/timeline/timeline.ts @@ -61,11 +61,11 @@ export class AddonBlockTimelineComponent extends AddonBlockComponent implements */ ngOnInit(): void { this.currentSite = this.sitesProvider.getCurrentSite(); - this.currentSite.getSiteConfig('AddonBlockTimelineFilter', this.filter).then((value) => { + this.currentSite.getLocalSiteConfig('AddonBlockTimelineFilter', this.filter).then((value) => { this.filter = value; this.switchFilter(); }); - this.currentSite.getSiteConfig('AddonBlockTimelineSort', this.sort).then((value) => { + this.currentSite.getLocalSiteConfig('AddonBlockTimelineSort', this.sort).then((value) => { this.sort = value; super.ngOnInit(); }); @@ -176,7 +176,7 @@ export class AddonBlockTimelineComponent extends AddonBlockComponent implements * Change timeline filter being viewed. */ switchFilter(): void { - this.currentSite.setSiteConfig('AddonBlockTimelineFilter', this.filter); + this.currentSite.setLocalSiteConfig('AddonBlockTimelineFilter', this.filter); switch (this.filter) { case 'overdue': this.dataFrom = -14; @@ -210,7 +210,7 @@ export class AddonBlockTimelineComponent extends AddonBlockComponent implements * Change timeline sort being viewed. */ switchSort(): void { - this.currentSite.setSiteConfig('AddonBlockTimelineSort', this.sort); + this.currentSite.setLocalSiteConfig('AddonBlockTimelineSort', this.sort); if (!this.timeline.loaded && this.sort == 'sortbydates') { this.fetchContent(); } else if (!this.timelineCourses.loaded && this.sort == 'sortbycourses') { diff --git a/src/classes/site.ts b/src/classes/site.ts index 24c2adc2c..b76499d21 100644 --- a/src/classes/site.ts +++ b/src/classes/site.ts @@ -1573,13 +1573,13 @@ export class CoreSite { } /** - * Get a site setting. + * Get a site setting on local device. * * @param {string} name The config name. * @param {any} [defaultValue] Default value to use if the entry is not found. * @return {Promise} Resolves upon success along with the config data. Reject on failure. */ - getSiteConfig(name: string, defaultValue?: any): Promise { + getLocalSiteConfig(name: string, defaultValue?: any): Promise { return this.db.getRecord(this.CONFIG_TABLE, { name: name }).then((entry) => { return entry.value; }).catch((error) => { @@ -1592,13 +1592,13 @@ export class CoreSite { } /** - * Set a site setting. + * Set a site setting on local device. * * @param {string} name The config name. * @param {number|string} value The config value. Can only store number or strings. * @return {Promise} Promise resolved when done. */ - setSiteConfig(name: string, value: number | string): Promise { + setLocalSiteConfig(name: string, value: number | string): Promise { return this.db.insertRecord(this.CONFIG_TABLE, { name: name, value: value }); } }