Skip to content

Commit

Permalink
only show subset of all events (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
agduncan94 authored Mar 12, 2019
1 parent 7184f48 commit a97d2e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/app/organizations/events/events.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<mat-card>
<mat-card-header>
<mat-card-title>
Recent Events
</mat-card-title>
</mat-card-header>
<app-loading [loading]="(loading$ | async)">
<div fxLayout="column wrap">
<span *ngFor="let event of (events$ | async)">
Expand Down
16 changes: 15 additions & 1 deletion src/app/organizations/state/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@ export class EventsService {
*/
updateOrganizationEvents(id: number): void {
this.eventsStore.setLoading(true);
this.organizationsService.getOrganizationEvents(id).pipe(
this.organizationsService.getOrganizationEvents(id, 0, 30).pipe(
finalize(() => this.eventsStore.setLoading(false)
))
.subscribe((organizationEvents: Array<Event>) => {
const EventType = Event.TypeEnum;
const importantEvents = [
EventType.CREATEORG,
EventType.APPROVEORGINVITE,
EventType.MODIFYORG,
EventType.CREATECOLLECTION,
EventType.MODIFYCOLLECTION,
EventType.ADDTOCOLLECTION,
EventType.REMOVEFROMCOLLECTION
];
// Only return important events
organizationEvents = organizationEvents.filter((event: Event) => importantEvents.includes(event.type));
// Only return at most 10 events
organizationEvents = organizationEvents.slice(0, 10);
this.eventsStore.set(organizationEvents);
}, () => {
this.eventsStore.setError(true);
Expand Down

0 comments on commit a97d2e6

Please sign in to comment.