|
|
@ -1,10 +1,11 @@
|
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Headers, Http} from '@angular/http';
|
|
|
|
import {Headers, Http, Request} from '@angular/http';
|
|
|
|
import {Login} from '../../models/login';
|
|
|
|
import {Login} from '../../models/login';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {DatasharingService} from '../datasharing.service';
|
|
|
|
import {DatasharingService} from '../datasharing.service';
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
providedIn: 'root'
|
|
|
@ -35,6 +36,7 @@ export class LoginService {
|
|
|
|
|
|
|
|
|
|
|
|
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.login.id;
|
|
|
|
user.userID = response.data.login.id;
|
|
|
|
user.username = response.data.login.name;
|
|
|
|
user.username = response.data.login.name;
|
|
|
@ -45,10 +47,19 @@ export class LoginService {
|
|
|
|
user.friendIDs = response.data.login.friends;
|
|
|
|
user.friendIDs = response.data.login.friends;
|
|
|
|
user.groupIDs = response.data.login.groups;
|
|
|
|
user.groupIDs = response.data.login.groups;
|
|
|
|
user.chatIDs = response.data.login.chats;
|
|
|
|
user.chatIDs = response.data.login.chats;
|
|
|
|
user.requestIDs = response.data.login.requests;
|
|
|
|
for (const request of response.data.login.sentRequests) {
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(user.receivedRequests);
|
|
|
|
this.data.changeUserInfo(user);
|
|
|
|
this.data.changeUserInfo(user);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public buildJson(login: Login): any {
|
|
|
|
public buildJson(login: Login): any {
|
|
|
@ -61,6 +72,8 @@ export class LoginService {
|
|
|
|
handle,
|
|
|
|
handle,
|
|
|
|
points,
|
|
|
|
points,
|
|
|
|
level,
|
|
|
|
level,
|
|
|
|
|
|
|
|
receivedRequests{id, sender{name, handle, id}},
|
|
|
|
|
|
|
|
sentRequests{receiver{id}},
|
|
|
|
friends {
|
|
|
|
friends {
|
|
|
|
id
|
|
|
|
id
|
|
|
|
},
|
|
|
|
},
|
|
|
|