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
+2 -2
View File
@@ -18,9 +18,9 @@
</div>
<div class="div-icon">
<!-- <button (click)="openChatDebuggingPageModal()" title="Nova Conversa Individual" class="btn-no-color font-12">
<button (click)="openChatDebuggingPageModal()" title="Nova Conversa Individual" class="btn-no-color font-12">
Dev
</button> -->
</button>
<button title="Nova Conversa Individual" class="btn-no-color" (click)="openContactsPage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src="assets/images/icons-chat-new-conversation.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src="assets/images/theme/gov/icons-chat-new-conversation.svg"></ion-icon>
+13 -13
View File
@@ -366,20 +366,20 @@ export class ChatService {
let options = {
headers: this.headers
};
return await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
}
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
}
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
// console.log(res)
// console.log(SessionStore.user.ChatData)
});
}
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
} else {
this.setheader()
}
@@ -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);
@@ -4,7 +4,7 @@
<div class="header-top">
<div class="middle">
<ion-label class="title">{{ this.wsChatMethodsService.getDmRoom(this.roomId).name }}</ion-label>
<!-- <button (click)="ChatMessageDebuggingPage()">Dev</button> -->
<button (click)="ChatMessageDebuggingPage()">Dev</button>
<!-- <span><ion-icon class="{{users.status}}" name="ellipse"></ion-icon></span> -->
</div>
<div hidden class="right">