Change level query to correspond to the new api

master
trivernis 4 years ago
parent 3d15e5a8d0
commit 5c339d53ba

@ -66,7 +66,7 @@ export class MainNavigationComponent implements OnInit {
this.loggedIn = user.loggedIn; this.loggedIn = user.loggedIn;
this.userId = user.userID; this.userId = user.userID;
this.username = user.username; this.username = user.username;
this.level = this.levellist.getLevelName(user.level); this.level = user.levelName;
this.points = user.points; this.points = user.points;
this.profileUrl = '/profile/' + this.userId; this.profileUrl = '/profile/' + this.userId;
if (this.user.darkmode === true && this.lighttheme) { if (this.user.darkmode === true && this.lighttheme) {

@ -63,7 +63,7 @@ export class ProfileComponent implements OnInit {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
this.userProfile.allowedToSendRequest = this.requestService.isAllowedToSendRequest(this.userProfile.userID, this.self); this.userProfile.allowedToSendRequest = this.requestService.isAllowedToSendRequest(this.userProfile.userID, this.self);
this.ownProfile = this.userProfile.userID === this.self.userID; this.ownProfile = this.userProfile.userID === this.self.userID;
this.rankname = this.levellist.getLevelName(this.userProfile.level); this.rankname = this.userProfile.levelName;
} else { } else {
this.profileNotFound = true; this.profileNotFound = true;
} }

@ -1,16 +1,17 @@
import {Levellist} from 'src/app/models/levellist'; import {Levellist} from 'src/app/models/levellist';
export class FriendInfo { export class FriendInfo {
levellist: Levellist = new Levellist();
id: number; id: number;
name: string; name: string;
rankname: string; rankname = 'Rookie';
profilePicture: string; profilePicture: string;
constructor(pId: number, pName: string, pLevel: number, pic: string) { constructor(id: number, name: string, level: {name: string}, pic: string) {
this.id = pId; this.id = id;
this.name = pName; this.name = name;
this.rankname = this.levellist.getLevelName(pLevel); if (level) {
this.rankname = level.name;
}
this.profilePicture = pic; this.profilePicture = pic;
} }
} }

@ -16,7 +16,7 @@ export interface IUser {
settings?: string; settings?: string;
level: number; level: {name: string, levelNumber: number};
points: number; points: number;

@ -12,7 +12,8 @@ export class User {
handle: string; handle: string;
email: string; email: string;
points: number; points: number;
level: number; level = 0;
levelName = 'Rookie';
profilePicture: string; profilePicture: string;
joinedAt: string; joinedAt: string;
friendCount: number; friendCount: number;
@ -36,7 +37,10 @@ export class User {
this.handle = userDataResponse.handle; this.handle = userDataResponse.handle;
this.email = userDataResponse.email; this.email = userDataResponse.email;
this.points = userDataResponse.points; this.points = userDataResponse.points;
this.level = userDataResponse.level; if (userDataResponse.level) {
this.level = userDataResponse.level.levelNumber;
this.levelName = userDataResponse.level.name;
}
this.profilePicture = this.buildProfilePictureUrl(userDataResponse.profilePicture); this.profilePicture = this.buildProfilePictureUrl(userDataResponse.profilePicture);
this.joinedAt = userDataResponse.joinedAt; this.joinedAt = userDataResponse.joinedAt;
this.friendCount = userDataResponse.friendCount; this.friendCount = userDataResponse.friendCount;

@ -105,7 +105,7 @@ export class ChatService {
for (const chat of temp.data.getSelf.chats) { for (const chat of temp.data.getSelf.chats) {
let memberID: number; let memberID: number;
let memberName: string; let memberName: string;
let memberLevel: number; let memberLevel: {name: string, levelNumber: number};
let profilePicture: string; let profilePicture: string;
for (const member of chat.members) { for (const member of chat.members) {
if (member.id !== this.ownID) { if (member.id !== this.ownID) {
@ -226,7 +226,7 @@ export class ChatService {
const body = { const body = {
query: `query { query: `query {
getSelf { getSelf {
chats(first: 1000, offset: 0) {members{name, id, level}} chats(first: 1000, offset: 0) {members{name, id, level {name levelNumber}}}
}}` }}`
}; };
@ -251,7 +251,7 @@ export class ChatService {
query: `query { query: `query {
getSelf { getSelf {
chats(first: 10, offset: 0) { chats(first: 10, offset: 0) {
id, members{name, id, level}, id, members{name, id, level {name levelNumber}},
messages(first: 10, offset: 0) { messages(first: 10, offset: 0) {
author {id}, createdAt, content author {id}, createdAt, content
} }
@ -265,7 +265,7 @@ export class ChatService {
getBodyForGetChatsByID(pChatID: number) { getBodyForGetChatsByID(pChatID: number) {
const body = { const body = {
query: `query($chatID: ID!) { query: `query($chatID: ID!) {
getChat(chatId: $chatID) {id, members{name, id, level}, getChat(chatId: $chatID) {id, members{name, id, level {name levelNumber}},
messages(first: 1000, offset: 0) {author {id}, createdAt, content}} messages(first: 1000, offset: 0) {author {id}, createdAt, content}}
} }
}`, variables: { }`, variables: {

@ -21,14 +21,20 @@ const graphqlQuery = `mutation($email: String!, $pwHash: String!) {
email, email,
handle, handle,
points, points,
level, level {
name
levelNumber
},
profilePicture, profilePicture,
receivedRequests{id, sender{name, handle, id}}, receivedRequests{id, sender{name, handle, id}},
sentRequests{receiver{id}}, sentRequests{receiver{id}},
friends { friends {
id, id,
name, name,
level, level {
name
levelNumber
},
profilePicture profilePicture
}, },
groups { groups {

@ -16,7 +16,10 @@ const graphqlGetProfileQuery = `query($userId: ID) {
name name
profilePicture profilePicture
points points
level level {
name
levelNumber
}
friendCount friendCount
groupCount groupCount
joinedAt joinedAt

@ -77,13 +77,19 @@ export class RegisterService {
name, name,
handle, handle,
points, points,
level, level {
name
levelNumber
},
receivedRequests{id, sender{name, handle, id}}, receivedRequests{id, sender{name, handle, id}},
sentRequests{receiver{id}} sentRequests{receiver{id}}
friends { friends {
id, id,
name, name,
level, level {
name
levelNumber
},
profilePicture profilePicture
}, },
groups{id}, groups{id},

@ -23,7 +23,10 @@ const graphqlQuery = `query($query: String!, $first: Int, $offset: Int) {
id, id,
handle, handle,
points, points,
level, level {
name
levelNumber
},
friends { friends {
id id
} }
@ -77,7 +80,10 @@ export class SearchService extends BaseService {
user.userID = foundUser.id; user.userID = foundUser.id;
user.handle = foundUser.handle; user.handle = foundUser.handle;
user.points = foundUser.points; user.points = foundUser.points;
user.level = foundUser.level; if (foundUser.level) {
user.level = foundUser.level.levelNumber;
user.levelName = foundUser.level.name;
}
// @ts-ignore // @ts-ignore
user.friends = foundUser.friends; user.friends = foundUser.friends;
users.push(user); users.push(user);

@ -14,14 +14,20 @@ const getSelfGraphqlQuery = `{
email, email,
handle, handle,
points, points,
level, level {
name
levelNumber
},
profilePicture, profilePicture,
receivedRequests{id, sender{name, handle, id}}, receivedRequests{id, sender{name, handle, id}},
sentRequests{receiver{id}}, sentRequests{receiver{id}},
friends { friends {
id, id,
name, name,
level, level {
name
levelNumber
},
profilePicture, profilePicture,
}, },
groups { groups {

Loading…
Cancel
Save