This commit is contained in:
tiago.kayaya
2022-01-14 11:53:14 +01:00
parent c4b6abe094
commit a8e2b48c33
5 changed files with 8 additions and 142 deletions
+3 -97
View File
@@ -138,39 +138,21 @@ export class ChatPage implements OnInit {
this.showLoader = true;
console.log("CHAT PAGE");
/* wsService.messages.subscribe(msg => {
console.log("Response from Websocket server: "+msg);
}); */
//this.load()
}
ngOnInit() {
console.log(this.loggedUserChat);
this.segment = "Contactos";
this.authService.userData$.subscribe((res: any) => {
this.loggedUser = res;
//console.log(this.loggedUser);
//this.load();
//this.getDirectMessagesDB();
});
/* websocket functions */
//this.sendMsg();
/* Fim websocket functions */
this.hideRefreshButton();
this.getChatMembers();
//Teste
let t = this.showDateDuration(new Date());
//console.log(t);
this.setStatus('away');
/* if(this.dataService.get("newGroup")){
@@ -232,28 +214,6 @@ export class ChatPage implements OnInit {
}
}
/* loadWsChatMessages(){
this.chatService.messages.subscribe(msg => {
console.log("Response from Websocket server: "+msg);
});
} */
/* loadMessage(){
this.wsService.messages.subscribe(msg => {
console.log("Response from websocket: " + msg);
});
}
sendMsg() {
console.log("new message from client to websocket: ", this.message);
this.wsService.messages.next(this.message);
this.message.msg = "";
this.loadMessage();
} */
/* Fim websockets functions */
closeAllDesktopComponents() {
this.showMessages = false;
this.showContacts = false;
@@ -396,33 +356,20 @@ export class ChatPage implements OnInit {
}
onSegmentChange() {
this.load();
//this.load();
}
doRefresh(event) {
setTimeout(() => {
this.load();
//this.load();
event.target.complete();
}, 1000);
}
refreshing() {
this.load();
//this.load();
}
load() {
switch (this.segment) {
case "Contactos":
this.showLoader = true;
this.getDirectMessages();
break;
case "Grupos":
this.showLoader = true;
this.getGroups();
break;
}
}
customRoom() {
let params = new HttpParams();
params = params.set("types", "c");
@@ -558,47 +505,6 @@ export class ChatPage implements OnInit {
}
}
async getDirectMessages(event?) {
this.chatService.getAllDirectMessages().subscribe(async (res: any) => {
this.showLoader = false;
this.transformDataRoomList(res.ims)
this.getDirectMessagesDB()
//console.log('Chat list', res);
if (res != 200) {
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.userDirectMessages = res.ims.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
});
} */
//console.log(res.ims);
//console.log(this.userDirectMessages);
if (this.route.url != "/home/chat") {
//console.log("Timer message stop")
}
else {
//console.log('TIMER');
//Check if modal is opened
if (this.segment == "Contactos" && this.showMessages != true) {
await new Promise(resolve => setTimeout(resolve, 1000));
//await this.getDirectMessages();
//console.log('Timer contactos list running')
}
else {
//console.log('No timer!');
}
}
}
else {
//await this.getDirectMessages();
}
});
}
showDateDuration(start: any) {
return this.timeService.showDateDuration(start);
}