From bb42e9b94dc5ac71acde7de394091ec3805ab9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 31 Jan 2022 13:38:13 +0100 Subject: [PATCH] MOBILE-3923 starredcourses: Use block WS when obtaining course list --- .../components/starredcourses/starredcourses.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts b/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts index 8e58120ad..8ec6cfaf9 100644 --- a/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts +++ b/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts @@ -18,7 +18,6 @@ import { CoreSites } from '@services/sites'; import { CoreCoursesProvider, CoreCoursesMyCoursesUpdatedEventData, CoreCourses } from '@features/courses/services/courses'; import { CoreCourseSearchedDataWithExtraInfoAndOptions, - CoreCoursesHelper, CoreEnrolledCourseDataWithOptions, } from '@features/courses/services/courses-helper'; import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate'; @@ -44,7 +43,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im downloadCourseEnabled = false; scrollElementId!: string; - protected site!: CoreSite; + protected site: CoreSite; protected isDestroyed = false; protected coursesObserver?: CoreEventObserver; protected updateSiteObserver?: CoreEventObserver; @@ -103,12 +102,8 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im protected async invalidateCourses(courseIds: number[]): Promise { const promises: Promise[] = []; - const invalidateCoursePromise = this.site.isVersionGreaterEqualThan('4.0') - ? CoreCourses.invalidateUserCourses() - : AddonBlockStarredCourses.invalidateStarredCourses(); - // Invalidate course completion data. - promises.push(invalidateCoursePromise.finally(() => + promises.push(AddonBlockStarredCourses.invalidateStarredCourses().finally(() => CoreUtils.allPromises(courseIds.map((courseId) => AddonCourseCompletion.invalidateCourseCompletion(courseId))))); @@ -131,12 +126,6 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im const showCategories = this.block.configsRecord && this.block.configsRecord.displaycategories && 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. const starredCourses = await AddonBlockStarredCourses.getStarredCourses();