diff --git a/projects/v3/src/app/components/activity/activity.component.html b/projects/v3/src/app/components/activity/activity.component.html index efa3d4ca5..78edd78c1 100644 --- a/projects/v3/src/app/components/activity/activity.component.html +++ b/projects/v3/src/app/components/activity/activity.component.html @@ -3,7 +3,7 @@

{{ activity.name }}

- +
@@ -20,7 +20,10 @@

{activity.tasks.length, plural, =1 {Task} other {Tasks}} - + +

+ + +
+ +
+
diff --git a/projects/v3/src/app/services/activity.service.ts b/projects/v3/src/app/services/activity.service.ts index d9e3cd50b..2f2e61658 100644 --- a/projects/v3/src/app/services/activity.service.ts +++ b/projects/v3/src/app/services/activity.service.ts @@ -99,9 +99,9 @@ export class ActivityService { } ).pipe( map(res => this._normaliseActivity(res.data, goToNextTask, afterTask)) - ).subscribe(_res => { + ).subscribe(res => { if (callback instanceof Function) { - return callback(_res); + return callback(res); } return; }); @@ -182,6 +182,11 @@ export class ActivityService { if (!tasks) { tasks = this.activity.tasks; } + + if (this.utils.isEmpty(tasks) || tasks.length === 0) { + tasks = []; + } + // find the first task that is not done or pending review // and is allowed to access for this user let skipTask = !!afterTask; @@ -216,14 +221,18 @@ export class ActivityService { } } } + // if there is no next task - if (!nextTask) { + if (this.utils.isEmpty(nextTask)) { if (afterTask) { return this._activityCompleted(hasUnfinishedTask); } nextTask = tasks[0]; } - this.goToTask(nextTask); + + if (!this.utils.isEmpty(nextTask)) { + return this.goToTask(nextTask); + } } private _activityCompleted(showPopup: boolean) {