From 8d753f957ed64206a3c9e9172102cf777c182cd8 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 29 Dec 2019 19:47:50 +0100 Subject: [PATCH] fixed SelfService Bug --- src/app/services/register/register.service.ts | 4 +-- src/app/services/selfservice/self.service.ts | 27 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/app/services/register/register.service.ts b/src/app/services/register/register.service.ts index 789cea6..51d4ae2 100644 --- a/src/app/services/register/register.service.ts +++ b/src/app/services/register/register.service.ts @@ -48,7 +48,7 @@ export class RegisterService { user.email = response.data.register.email; user.points = response.data.register.points; user.level = response.data.register.level; - for (const friend of response.data.login.friends) { + for (const friend of response.data.register.friends) { user.friends.push(new FriendInfo(friend.id, friend.name, friend.level)); } user.groupIDs = response.data.register.groups; @@ -56,7 +56,7 @@ export class RegisterService { for (const request of response.data.register.sentRequests) { user.sentRequestUserIDs.push(request.receiver.id); } - for (const request of response.data.login.receivedRequests) { + for (const request of response.data.register.receivedRequests) { friendRequest = new FriendRequest(); friendRequest.id = request.id; friendRequest.senderUserID = request.sender.id; diff --git a/src/app/services/selfservice/self.service.ts b/src/app/services/selfservice/self.service.ts index 4f29f31..05127d9 100644 --- a/src/app/services/selfservice/self.service.ts +++ b/src/app/services/selfservice/self.service.ts @@ -32,6 +32,8 @@ export class SelfService { }, error => { this.notLoggedIn(); console.log(error.text()); + // this.fakeLogin(); + // console.log('user wurde übergeben'); } ); } @@ -53,7 +55,7 @@ export class SelfService { user.email = response.data.getSelf.email; user.points = response.data.getSelf.points; user.level = response.data.getSelf.level; - for (const friend of response.data.login.friends) { + for (const friend of response.data.getSelf.friends) { user.friends.push(new FriendInfo(friend.id, friend.name, friend.level)); } user.groupIDs = response.data.getSelf.groups; @@ -61,7 +63,7 @@ export class SelfService { for (const request of response.data.getSelf.sentRequests) { user.sentRequestUserIDs.push(request.receiver.id); } - for (const request of response.data.login.receivedRequests) { + for (const request of response.data.getSelf.receivedRequests) { friendRequest = new FriendRequest(); friendRequest.id = request.id; friendRequest.senderUserID = request.sender.id; @@ -71,6 +73,27 @@ export class SelfService { } this.data.changeUserInfo(user); } + public fakeLogin() { + const user: User = new User(); + let friendRequest: FriendRequest = new FriendRequest(); + user.loggedIn = true; + user.userID = 1; + user.username = 'Rapier'; + user.handle = 'rapier123'; + user.email = 'r@r.com'; + user.points = 100; + user.level = 3; + user.friends.push(new FriendInfo(1, 'Freund77', 4)); + + friendRequest = new FriendRequest(); + friendRequest.id = 10; + friendRequest.senderUserID = 99; + friendRequest.senderUsername = 'Löwe'; + friendRequest.senderHandle = 'loewe123'; + user.receivedRequests.push(friendRequest); + + this.data.changeUserInfo(user); + } public buildJson(): any { const body = {query: `{