|
|
@ -89,8 +89,12 @@ export class ChatService {
|
|
|
|
this.http.post(url, this.getBodyForNewChat(pUserID));
|
|
|
|
this.http.post(url, this.getBodyForNewChat(pUserID));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* TODO: Needs to be used somewhere or it will be removed
|
|
|
|
|
|
|
|
*/
|
|
|
|
public requestAllChatPartners(): Array<FriendInfo> {
|
|
|
|
public requestAllChatPartners(): Array<FriendInfo> {
|
|
|
|
const url = environment.graphQLUrl;
|
|
|
|
const url = environment.graphQLUrl;
|
|
|
|
|
|
|
|
// tslint:disable-next-line:prefer-const
|
|
|
|
let chatPartners: Array<FriendInfo>;
|
|
|
|
let chatPartners: Array<FriendInfo>;
|
|
|
|
let temp;
|
|
|
|
let temp;
|
|
|
|
|
|
|
|
|
|
|
@ -107,7 +111,7 @@ export class ChatService {
|
|
|
|
let memberName: string;
|
|
|
|
let memberName: string;
|
|
|
|
let memberLevel: number;
|
|
|
|
let memberLevel: number;
|
|
|
|
for (const member of chat.members) {
|
|
|
|
for (const member of chat.members) {
|
|
|
|
if (member.id != this.ownID) {
|
|
|
|
if (member.id !== this.ownID) {
|
|
|
|
memberID = member.id;
|
|
|
|
memberID = member.id;
|
|
|
|
memberName = member.name;
|
|
|
|
memberName = member.name;
|
|
|
|
memberLevel = member.level;
|
|
|
|
memberLevel = member.level;
|
|
|
@ -154,7 +158,7 @@ export class ChatService {
|
|
|
|
public renderMessages(pResponse: any): Array<Chatmessage> {
|
|
|
|
public renderMessages(pResponse: any): Array<Chatmessage> {
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
for (const message of pResponse.data.getChat.messages) {
|
|
|
|
for (const message of pResponse.data.getChat.messages) {
|
|
|
|
if (message.author.id == this.ownID) {
|
|
|
|
if (message.author.id === this.ownID) {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
@ -169,14 +173,14 @@ export class ChatService {
|
|
|
|
let memberID: number;
|
|
|
|
let memberID: number;
|
|
|
|
let memberName: string;
|
|
|
|
let memberName: string;
|
|
|
|
for (const member of chat.members) {
|
|
|
|
for (const member of chat.members) {
|
|
|
|
if (member.id != this.ownID) {
|
|
|
|
if (member.id !== this.ownID) {
|
|
|
|
memberID = member.id;
|
|
|
|
memberID = member.id;
|
|
|
|
memberName = member.name;
|
|
|
|
memberName = member.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
for (const message of chat.messages) {
|
|
|
|
for (const message of chat.messages) {
|
|
|
|
if (message.author.id == this.ownID) {
|
|
|
|
if (message.author.id === this.ownID) {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
@ -192,14 +196,14 @@ export class ChatService {
|
|
|
|
let memberId: number;
|
|
|
|
let memberId: number;
|
|
|
|
let memberName: string;
|
|
|
|
let memberName: string;
|
|
|
|
for (const member of pResponse.data.getChat.members) {
|
|
|
|
for (const member of pResponse.data.getChat.members) {
|
|
|
|
if (member.id != this.ownID) {
|
|
|
|
if (member.id !== this.ownID) {
|
|
|
|
memberId = member.id;
|
|
|
|
memberId = member.id;
|
|
|
|
memberName = member.name;
|
|
|
|
memberName = member.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
const messages = new Array<Chatmessage>();
|
|
|
|
for (const message of pResponse.data.getChat.messages) {
|
|
|
|
for (const message of pResponse.data.getChat.messages) {
|
|
|
|
if (message.author.id == this.ownID) {
|
|
|
|
if (message.author.id === this.ownID) {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, true));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
|
messages.push(new Chatmessage(message.content, message.createdAt, false));
|
|
|
|