This commit is contained in:
Peter Maquiran
2022-09-29 14:44:21 +01:00
parent 530305a3dc
commit 68d8753abd
4 changed files with 64 additions and 21 deletions
@@ -98,6 +98,7 @@ export class WsChatMethodsService {
}
async ReLoadChat() {
await this.chatService.refreshtoken();
await this.restoreRooms();
await this.getAllRooms();
this.subscribeToRoom();
@@ -183,9 +184,22 @@ export class WsChatMethodsService {
const roomId = this.getRoomId(roomData);
if(roomData.t == 'd') {
const res = await this.chatService.getMembers(roomId).toPromise();
let error = false
let res;
try {
res = await this.chatService.getMembers(roomId).toPromise();
} catch (e) {
await this.chatService.refreshtoken();
error = true
}
if(error) {
res = await this.chatService.getMembers(roomId).toPromise();
}
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
rooms.result.update[index]['members'] = users
@@ -193,7 +207,20 @@ export class WsChatMethodsService {
await this.prepareRoom(roomData);
} else {
if (roomData.t === 'p') {
const res = await this.chatService.getGroupMembers(roomId).toPromise()
let error = false
let res;
try {
res = await this.chatService.getGroupMembers(roomId).toPromise()
} catch (e) {
await this.chatService.refreshtoken();
error = true
}
if(error) {
res = await this.chatService.getGroupMembers(roomId).toPromise()
}
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
@@ -203,7 +230,23 @@ export class WsChatMethodsService {
}
else {
const res = await this.chatService.getChannelMembers(roomId).toPromise()
let error = false
let res;
try {
res = await this.chatService.getChannelMembers(roomId).toPromise()
} catch (e) {
await this.chatService.refreshtoken();
error = true
}
if(error) {
res = await this.chatService.getChannelMembers(roomId).toPromise()
}
const members = res['members'];
const users = members.filter(data => data.username != this.sessionStore.user.UserName);