From 6be3d682304e12d2142c7bffbf24e5e58ff7f172 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 3 May 2024 14:55:51 +0200 Subject: [PATCH] MOBILE-4470 course: Show all sections if last module is stealth --- .../components/course-format/course-format.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/features/course/components/course-format/course-format.ts b/src/core/features/course/components/course-format/course-format.ts index a7788810a..c658ea48a 100644 --- a/src/core/features/course/components/course-format/course-format.ts +++ b/src/core/features/course/components/course-format/course-format.ts @@ -382,18 +382,18 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { sections: CoreCourseSection[], viewedModule: CoreCourseViewedModulesDBRecord, ): CoreCourseSection | undefined { - if (viewedModule.sectionId) { - const lastModuleSection = sections.find(section => section.id === viewedModule.sectionId); + let lastModuleSection: CoreCourseSection | undefined; - if (lastModuleSection) { - return lastModuleSection; - } + if (viewedModule.sectionId) { + lastModuleSection = sections.find(section => section.id === viewedModule.sectionId); } - // No sectionId or section not found. Search the module. - return sections.find( - section => section.modules.some(module => module.id === viewedModule.cmId), - ); + if (!lastModuleSection) { + // No sectionId or section not found. Search the module. + lastModuleSection = sections.find(section => section.modules.some(module => module.id === viewedModule.cmId)); + } + + return lastModuleSection && lastModuleSection.id !== this.stealthModulesSectionId ? lastModuleSection : undefined; } /**