fixed request bug

master
Max 5 years ago
parent fee4778f30
commit 5998c8c20f

@ -117,32 +117,33 @@ export class MainNavigationComponent implements OnInit {
} }
acceptRequest(id: number) { acceptRequest(id: number) {
for (let i = 0; i < this.user.receivedRequests.length; i++) { console.log('try to accept request from id: ' + id);
if (this.user.receivedRequests[i].senderUserID === id) {
this.user.receivedRequests.splice(i, 1);
return;
}
}
const headers = new Headers(); const headers = new Headers();
headers.set('Content-Type', 'application/json'); headers.set('Content-Type', 'application/json');
this.http.post(environment.graphQLUrl, this.requestservice.buildJsonAcceptRequest(id)) this.http.post(environment.graphQLUrl, this.requestservice.buildJsonAcceptRequest(id))
.subscribe(response => { .subscribe(response => {
console.log(response); console.log(response);
});
}
denyRequest(id: number) {
for (let i = 0; i < this.user.receivedRequests.length; i++) { for (let i = 0; i < this.user.receivedRequests.length; i++) {
if (this.user.receivedRequests[i].senderUserID === id) { if (this.user.receivedRequests[i].senderUserID === id) {
this.user.receivedRequests.splice(i, 1); this.user.receivedRequests.splice(i, 1);
return; return;
} }
} }
});
}
denyRequest(id: number) {
const headers = new Headers(); const headers = new Headers();
headers.set('Content-Type', 'application/json'); headers.set('Content-Type', 'application/json');
this.http.post(environment.graphQLUrl, this.requestservice.buildJsonDenyRequest(id)) this.http.post(environment.graphQLUrl, this.requestservice.buildJsonDenyRequest(id))
.subscribe(response => { .subscribe(response => {
console.log(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;
}
}
}); });
} }
} }

Loading…
Cancel
Save