From 655e0fb56866fe6fd1bb6717cd77486fccefaaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 13 Aug 2018 10:26:18 +0200 Subject: [PATCH] [28151] Fix activity numbers when taking newest elements https://community.openproject.com/wp/28151 --- .../activity-on-overview.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts b/frontend/src/app/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts index 31926fe74f..5e6f2bec08 100644 --- a/frontend/src/app/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts +++ b/frontend/src/app/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts @@ -65,7 +65,17 @@ export class NewestActivityOnOverviewComponent extends ActivityPanelBaseControll } private latestActivities(visible:number = 3) { - let segment = this.unfilteredActivities.slice(-visible); - return segment.map((el:HalResource, i:number) => this.info(el, i)); + + if (this.reverse) { + // In reverse, we already get reversed entries from API. + // So simply take the first three + let segment = this.unfilteredActivities.slice(0, visible); + return segment.map((el:HalResource, i:number) => this.info(el, i)); + } else { + // In ascending sort, take the last three items + let segment = this.unfilteredActivities.slice(-visible); + let startIndex = this.unfilteredActivities.length - segment.length; + return segment.map((el:HalResource, i:number) => this.info(el, startIndex + i)); + } } }