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[],
viewedModule: CoreCourseViewedModulesDBRecord,
): CoreCourseSection | undefined {
let lastModuleSection: CoreCourseSection | undefined;
if (viewedModule.sectionId) {
const lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
if (lastModuleSection) {
return lastModuleSection;
}
lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
}
if (!lastModuleSection) {
// No sectionId or section not found. Search the module.
return sections.find(
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;
}
/**