From 5998c8c20fabaf11b6f48f93bdcf4710a20d4106 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 29 Dec 2019 01:49:49 +0100 Subject: [PATCH] fixed request bug --- .../main-navigation.component.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app/components/main-navigation/main-navigation.component.ts b/src/app/components/main-navigation/main-navigation.component.ts index ef35efb..f8f7667 100644 --- a/src/app/components/main-navigation/main-navigation.component.ts +++ b/src/app/components/main-navigation/main-navigation.component.ts @@ -117,32 +117,33 @@ export class MainNavigationComponent implements OnInit { } acceptRequest(id: number) { - for (let i = 0; i < this.user.receivedRequests.length; i++) { - if (this.user.receivedRequests[i].senderUserID === id) { - this.user.receivedRequests.splice(i, 1); - return; - } - } + console.log('try to accept request from id: ' + id); const headers = new Headers(); headers.set('Content-Type', 'application/json'); this.http.post(environment.graphQLUrl, this.requestservice.buildJsonAcceptRequest(id)) .subscribe(response => { console.log(response); + for (let i = 0; i < this.user.receivedRequests.length; i++) { + if (this.user.receivedRequests[i].senderUserID === id) { + this.user.receivedRequests.splice(i, 1); + return; + } + } }); } denyRequest(id: number) { - for (let i = 0; i < this.user.receivedRequests.length; i++) { - if (this.user.receivedRequests[i].senderUserID === id) { - this.user.receivedRequests.splice(i, 1); - return; - } - } const headers = new Headers(); headers.set('Content-Type', 'application/json'); this.http.post(environment.graphQLUrl, this.requestservice.buildJsonDenyRequest(id)) .subscribe(response => { console.log(response); + for (let i = 0; i < this.user.receivedRequests.length; i++) { + if (this.user.receivedRequests[i].senderUserID === id) { + this.user.receivedRequests.splice(i, 1); + return; + } + } }); } }