Skip to content

Commit

Permalink
MOBILE-4470 course: Delete files linked to course component
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed May 22, 2024
1 parent 91c5625 commit 40032e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/features/course/services/course-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1912,12 +1912,14 @@ export class CoreCourseHelperProvider {
* @returns Promise to be resolved once the course files are deleted.
*/
async deleteCourseFiles(courseId: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
const sections = await CoreCourse.getSections(courseId);
const modules = sections.map((section) => section.modules).flat();

await Promise.all(
modules.map((module) => this.removeModuleStoredData(module, courseId)),
);
await Promise.all([
...modules.map((module) => this.removeModuleStoredData(module, courseId)),
siteId && CoreFilepool.removeFilesByComponent(siteId, CoreCourseProvider.COMPONENT, courseId),
]);

await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED);
}
Expand Down

0 comments on commit 40032e7

Please sign in to comment.