Merge pull request #3080 from crazyserver/MOBILE-3923

MOBILE-3923 starredcourses: Use block WS when obtaining course list
main
Dani Palou 2022-01-31 14:07:10 +01:00 committed by GitHub
commit f07d087947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 13 deletions

View File

@ -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<void> {
const promises: Promise<void>[] = [];
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();