From 4c94b61eca7b0ae4d47f914b059f34a4ba877b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 8 Nov 2021 16:19:08 +0100 Subject: [PATCH] MOBILE-3833 timeline: Hide courses without events --- .../components/timeline/addon-block-timeline.html | 2 +- src/addons/block/timeline/components/timeline/timeline.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/addons/block/timeline/components/timeline/addon-block-timeline.html b/src/addons/block/timeline/components/timeline/addon-block-timeline.html index 81c32360d..a955b9b69 100644 --- a/src/addons/block/timeline/components/timeline/addon-block-timeline.html +++ b/src/addons/block/timeline/components/timeline/addon-block-timeline.html @@ -47,6 +47,6 @@ [course]="course" [from]="dataFrom" [to]="dataTo"> + [message]="'addon.block_timeline.noevents' | translate"> diff --git a/src/addons/block/timeline/components/timeline/timeline.ts b/src/addons/block/timeline/components/timeline/timeline.ts index c8ef64b77..2eb6979df 100644 --- a/src/addons/block/timeline/components/timeline/timeline.ts +++ b/src/addons/block/timeline/components/timeline/timeline.ts @@ -176,9 +176,15 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen const courseEvents = await AddonBlockTimeline.getActionEventsByCourses(this.courseIds); - this.timelineCourses.courses.forEach((course) => { + this.timelineCourses.courses = this.timelineCourses.courses.filter((course) => { + if (courseEvents[course.id].events.length == 0) { + return false; + } + course.events = courseEvents[course.id].events; course.canLoadMore = courseEvents[course.id].canLoadMore; + + return true; }); } }