MOBILE-4470 course: Show all sections if last module is stealth

main
Dani Palou 2024-05-03 14:55:51 +02:00
parent 770b182ed6
commit 6be3d68230
1 changed files with 9 additions and 9 deletions

View File

@ -382,18 +382,18 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
sections: CoreCourseSection[], sections: CoreCourseSection[],
viewedModule: CoreCourseViewedModulesDBRecord, viewedModule: CoreCourseViewedModulesDBRecord,
): CoreCourseSection | undefined { ): CoreCourseSection | undefined {
if (viewedModule.sectionId) { let lastModuleSection: CoreCourseSection | undefined;
const lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
if (lastModuleSection) { if (viewedModule.sectionId) {
return lastModuleSection; lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
}
} }
// No sectionId or section not found. Search the module. if (!lastModuleSection) {
return sections.find( // No sectionId or section not found. Search the module.
section => section.modules.some(module => module.id === viewedModule.cmId), lastModuleSection = sections.find(section => section.modules.some(module => module.id === viewedModule.cmId));
); }
return lastModuleSection && lastModuleSection.id !== this.stealthModulesSectionId ? lastModuleSection : undefined;
} }
/** /**