|
|
@ -6,6 +6,8 @@ import { DatasharingService } from '../datasharing.service';
|
|
|
|
import { userInfo } from 'os';
|
|
|
|
import { userInfo } from 'os';
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
|
|
|
import { FriendRequest } from 'src/app/models/friendRequest';
|
|
|
|
|
|
|
|
import { FriendInfo } from 'src/app/models/friendinfo';
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
providedIn: 'root'
|
|
|
@ -43,6 +45,7 @@ export class SelfService {
|
|
|
|
|
|
|
|
|
|
|
|
public updateUserInfo(response: any) {
|
|
|
|
public updateUserInfo(response: any) {
|
|
|
|
const user: User = new User();
|
|
|
|
const user: User = new User();
|
|
|
|
|
|
|
|
let friendRequest: FriendRequest = new FriendRequest();
|
|
|
|
user.loggedIn = true;
|
|
|
|
user.loggedIn = true;
|
|
|
|
user.userID = response.data.getSelf.id;
|
|
|
|
user.userID = response.data.getSelf.id;
|
|
|
|
user.username = response.data.getSelf.name;
|
|
|
|
user.username = response.data.getSelf.name;
|
|
|
@ -50,19 +53,48 @@ export class SelfService {
|
|
|
|
user.email = response.data.getSelf.email;
|
|
|
|
user.email = response.data.getSelf.email;
|
|
|
|
user.points = response.data.getSelf.points;
|
|
|
|
user.points = response.data.getSelf.points;
|
|
|
|
user.level = response.data.getSelf.level;
|
|
|
|
user.level = response.data.getSelf.level;
|
|
|
|
user.friendIDs = response.data.getSelf.friends;
|
|
|
|
for (const friend of response.data.login.friends) {
|
|
|
|
|
|
|
|
user.friends.push(new FriendInfo(friend.id, friend.name, friend.level));
|
|
|
|
|
|
|
|
}
|
|
|
|
user.groupIDs = response.data.getSelf.groups;
|
|
|
|
user.groupIDs = response.data.getSelf.groups;
|
|
|
|
user.chatIDs = response.data.getSelf.chats;
|
|
|
|
user.chatIDs = response.data.getSelf.chats;
|
|
|
|
for (const request of response.data.getSelf.sentRequests) {
|
|
|
|
for (const request of response.data.getSelf.sentRequests) {
|
|
|
|
user.sentRequestUserIDs.push(request.receiver.id);
|
|
|
|
user.sentRequestUserIDs.push(request.receiver.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const request of response.data.login.receivedRequests) {
|
|
|
|
|
|
|
|
friendRequest = new FriendRequest();
|
|
|
|
|
|
|
|
friendRequest.id = request.id;
|
|
|
|
|
|
|
|
friendRequest.senderUserID = request.sender.id;
|
|
|
|
|
|
|
|
friendRequest.senderUsername = request.sender.name;
|
|
|
|
|
|
|
|
friendRequest.senderHandle = request.sender.handle;
|
|
|
|
|
|
|
|
user.receivedRequests.push(friendRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
this.data.changeUserInfo(user);
|
|
|
|
this.data.changeUserInfo(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public buildJson(): any {
|
|
|
|
public buildJson(): any {
|
|
|
|
const body = {query: `{
|
|
|
|
const body = {query: `{
|
|
|
|
getSelf{id, name, email, handle, points, level, sentRequests{receiver{id}}, friends{id}, groups{id},chats{id}}
|
|
|
|
getSelf{
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
email,
|
|
|
|
|
|
|
|
handle,
|
|
|
|
|
|
|
|
points,
|
|
|
|
|
|
|
|
level,
|
|
|
|
|
|
|
|
receivedRequests{id, sender{name, handle, id}},
|
|
|
|
|
|
|
|
sentRequests{receiver{id}},
|
|
|
|
|
|
|
|
friends {
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
level
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
groups {
|
|
|
|
|
|
|
|
id
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
chats{
|
|
|
|
|
|
|
|
id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}`, variables: {
|
|
|
|
}`, variables: {
|
|
|
|
}};
|
|
|
|
}};
|
|
|
|
return body;
|
|
|
|
return body;
|
|
|
|