MOBILE-3923 starredcourses: Use block WS when obtaining course list
parent
6428bbb5fc
commit
bb42e9b94d
|
@ -18,7 +18,6 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreCoursesProvider, CoreCoursesMyCoursesUpdatedEventData, CoreCourses } from '@features/courses/services/courses';
|
import { CoreCoursesProvider, CoreCoursesMyCoursesUpdatedEventData, CoreCourses } from '@features/courses/services/courses';
|
||||||
import {
|
import {
|
||||||
CoreCourseSearchedDataWithExtraInfoAndOptions,
|
CoreCourseSearchedDataWithExtraInfoAndOptions,
|
||||||
CoreCoursesHelper,
|
|
||||||
CoreEnrolledCourseDataWithOptions,
|
CoreEnrolledCourseDataWithOptions,
|
||||||
} from '@features/courses/services/courses-helper';
|
} from '@features/courses/services/courses-helper';
|
||||||
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
|
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
|
||||||
|
@ -44,7 +43,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
||||||
downloadCourseEnabled = false;
|
downloadCourseEnabled = false;
|
||||||
scrollElementId!: string;
|
scrollElementId!: string;
|
||||||
|
|
||||||
protected site!: CoreSite;
|
protected site: CoreSite;
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
protected coursesObserver?: CoreEventObserver;
|
protected coursesObserver?: CoreEventObserver;
|
||||||
protected updateSiteObserver?: CoreEventObserver;
|
protected updateSiteObserver?: CoreEventObserver;
|
||||||
|
@ -103,12 +102,8 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
||||||
protected async invalidateCourses(courseIds: number[]): Promise<void> {
|
protected async invalidateCourses(courseIds: number[]): Promise<void> {
|
||||||
const promises: Promise<void>[] = [];
|
const promises: Promise<void>[] = [];
|
||||||
|
|
||||||
const invalidateCoursePromise = this.site.isVersionGreaterEqualThan('4.0')
|
|
||||||
? CoreCourses.invalidateUserCourses()
|
|
||||||
: AddonBlockStarredCourses.invalidateStarredCourses();
|
|
||||||
|
|
||||||
// Invalidate course completion data.
|
// Invalidate course completion data.
|
||||||
promises.push(invalidateCoursePromise.finally(() =>
|
promises.push(AddonBlockStarredCourses.invalidateStarredCourses().finally(() =>
|
||||||
CoreUtils.allPromises(courseIds.map((courseId) =>
|
CoreUtils.allPromises(courseIds.map((courseId) =>
|
||||||
AddonCourseCompletion.invalidateCourseCompletion(courseId)))));
|
AddonCourseCompletion.invalidateCourseCompletion(courseId)))));
|
||||||
|
|
||||||
|
@ -131,12 +126,6 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
||||||
const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories &&
|
const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories &&
|
||||||
this.block.configsRecord.displaycategories.value == '1';
|
this.block.configsRecord.displaycategories.value == '1';
|
||||||
|
|
||||||
if (this.site.isVersionGreaterEqualThan('4.0')) {
|
|
||||||
this.courses = await CoreCoursesHelper.getUserCoursesWithOptions('timemodified', 0, 'isfavourite', showCategories);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timemodified not present, use the block WS to retrieve the info.
|
// Timemodified not present, use the block WS to retrieve the info.
|
||||||
const starredCourses = await AddonBlockStarredCourses.getStarredCourses();
|
const starredCourses = await AddonBlockStarredCourses.getStarredCourses();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue