From 5090186ccad3a308ad6f30961134e936ac3efc6e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 7 Aug 2023 14:50:36 +0200 Subject: [PATCH] MOBILE-4370 course: Remove unneeded 'Show more' in availability --- src/core/features/course/services/course.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 6788eb699..13217003d 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -704,6 +704,7 @@ export class CoreCourseProvider { course: courseId, section: sectionId, completiondata: completionData, + availabilityinfo: this.treatAvailablityInfo(module.availabilityinfo), }; } @@ -998,6 +999,7 @@ export class CoreCourseProvider { // Add course to all modules. return sections.map((section) => ({ ...section, + availabilityinfo: this.treatAvailablityInfo(section.availabilityinfo), modules: section.modules.map((module) => this.addAdditionalModuleData(module, courseId, section.id)), })); }), @@ -1555,6 +1557,21 @@ export class CoreCourseProvider { }, siteId); } + /** + * Treat availability info HTML. + * + * @param availabilityInfo HTML to treat. + * @returns Treated HTML. + */ + protected treatAvailablityInfo(availabilityInfo?: string): string | undefined { + if (!availabilityInfo) { + return availabilityInfo; + } + + // Remove "Show more" option in 4.2 or older sites. + return CoreDomUtils.removeElementFromHtml(availabilityInfo, 'li[data-action="showmore"]'); + } + } export const CoreCourse = makeSingleton(CoreCourseProvider);