From daec3e8433c3ca07bb725f86cb44ca108b5825fa Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Fri, 11 Oct 2019 16:11:39 +0200
Subject: [PATCH] Hide rejected participations on my event list

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 js/src/views/Event/MyEvents.vue |  4 ++--
 js/src/views/Home.vue           | 13 ++++++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/js/src/views/Event/MyEvents.vue b/js/src/views/Event/MyEvents.vue
index e080d64fa..ad0a3fddf 100644
--- a/js/src/views/Event/MyEvents.vue
+++ b/js/src/views/Event/MyEvents.vue
@@ -70,7 +70,7 @@
 <script lang="ts">
 import { Component, Prop, Vue } from 'vue-property-decorator';
 import { LOGGED_USER_PARTICIPATIONS, LOGGED_USER_DRAFTS } from '@/graphql/actor';
-import { EventModel, IEvent, IParticipant, Participant } from '@/types/event.model';
+import { EventModel, IEvent, IParticipant, Participant, ParticipantRole } from '@/types/event.model';
 import EventListCard from '@/components/Event/EventListCard.vue';
 import EventCard from '@/components/Event/EventCard.vue';
 
@@ -134,7 +134,7 @@ export default class MyEvents extends Vue {
   drafts: IEvent[] = [];
 
   private monthlyParticipations(participations: IParticipant[]): Map<string, Participant[]> {
-    const res = participations.filter(({ event }) => event.beginsOn != null);
+    const res = participations.filter(({ event, role }) => event.beginsOn != null && role !== ParticipantRole.REJECTED);
     res.sort(
           (a: IParticipant, b: IParticipant) => a.event.beginsOn.getTime() - b.event.beginsOn.getTime(),
       );
diff --git a/js/src/views/Home.vue b/js/src/views/Home.vue
index 6f08954fe..8f6f8fbea 100644
--- a/js/src/views/Home.vue
+++ b/js/src/views/Home.vue
@@ -107,7 +107,7 @@ import { IPerson, Person } from '@/types/actor';
 import { ICurrentUser } from '@/types/current-user.model';
 import { CURRENT_USER_CLIENT } from '@/graphql/user';
 import { RouteName } from '@/router';
-import { EventModel, IEvent, IParticipant, Participant } from '@/types/event.model';
+import { EventModel, IEvent, IParticipant, Participant, ParticipantRole } from '@/types/event.model';
 import DateComponent from '@/components/Event/DateCalendarIcon.vue';
 import { CONFIG } from '@/graphql/config';
 import { IConfig } from '@/types/config.model';
@@ -212,8 +212,11 @@ export default class Home extends Vue {
   }
 
   get goingToEvents(): Map<string, Map<string, IParticipant>> {
-    const res = this.currentUserParticipations.filter(({ event }) => {
-      return event.beginsOn != null && this.isAfter(event.beginsOn.toDateString(), 0) && this.isBefore(event.beginsOn.toDateString(), 7);
+    const res = this.currentUserParticipations.filter(({ event, role }) => {
+      return event.beginsOn != null &&
+              this.isAfter(event.beginsOn.toDateString(), 0) &&
+              this.isBefore(event.beginsOn.toDateString(), 7) &&
+              role !== ParticipantRole.REJECTED;
     });
     res.sort(
             (a: IParticipant, b: IParticipant) => a.event.beginsOn.getTime() - b.event.beginsOn.getTime(),
@@ -229,8 +232,8 @@ export default class Home extends Vue {
   }
 
   get lastWeekEvents() {
-    const res = this.currentUserParticipations.filter(({ event }) => {
-      return event.beginsOn != null && this.isBefore(event.beginsOn.toDateString(), 0);
+    const res = this.currentUserParticipations.filter(({ event, role }) => {
+      return event.beginsOn != null && this.isBefore(event.beginsOn.toDateString(), 0) && role !== ParticipantRole.REJECTED;
     });
     res.sort(
           (a: IParticipant, b: IParticipant) => a.event.beginsOn.getTime() - b.event.beginsOn.getTime(),