[28151] Fix activity numbers when taking newest elements

https://community.openproject.com/wp/28151
pull/6509/head
Oliver Günther 6 years ago
parent af2a64f03d
commit 655e0fb568
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 14
      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));
}
}
}

Loading…
Cancel
Save