From 50cf97e677e8078cae55d82ea8e508f8305f1ec6 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Fri, 20 Aug 2021 19:10:13 +0100 Subject: [PATCH 1/2] save --- src/app/pages/chat/chat.page.ts | 63 +++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 16c295461..d83e749cd 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -115,7 +115,7 @@ export class ChatPage implements OnInit { private authService: AuthService, private storage:Storage, private resolver: ComponentFactoryResolver, - private router: Router, + private route: Router, ){ this.loggedUserChat = authService.ValidatedUserChat['data']; this.headers = new HttpHeaders(); @@ -355,20 +355,34 @@ hideRefreshButton(){ }); } - getDirectMessages(){ - this.showLoader = true; + async getDirectMessages(){ - this.chatService.getAllDirectMessages().subscribe((res:any)=>{ - console.log(res.ims); + this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{ - 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(this.userDirectMessages); - this.showLoader = false; + if(res.ims != 200){ + console.log(res.ims); + 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(this.userDirectMessages); + if(this.route.url != "/home/chat"){ + console.log("Timer message stop") + } + else { + //Check if modal is opened + if(this.segment == "Contactos"){ + await new Promise(resolve => setTimeout(resolve, 5000)); + await this.getDirectMessages(); + console.log('Timer contactos list running') + } + } + } + else{ + await this.getDirectMessages(); + } }); } @@ -418,9 +432,13 @@ hideRefreshButton(){ console.log(this.dmUsers); }); } - getGroups(){ + + async getGroups(){ this.showLoader = true; - this.result = this.chatService.getAllPrivateGroups().subscribe((res:any)=>{ + this.result = this.chatService.getAllPrivateGroups().subscribe(async (res:any)=>{ + + if(res.groups != 200){ + this.privateGroups = res.groups; /* this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{ this.publicGroups = res.channels; */ @@ -433,6 +451,23 @@ hideRefreshButton(){ console.log(this.allGroups); this.showLoader = false; /* }); */ + if(this.route.url != "/home/chat"){ + console.log("Timer message stop") + } + else { + //Check if modal is opened + if(this.segment == "Grupos"){ + await new Promise(resolve => setTimeout(resolve, 5000)); + await this.getGroups(); + console.log('Timer groups list running') + } + } + + } + else{ + await this.getGroups(); + } + }); } From d425e13b5ba18f458c27d446782a8b7073efb39a Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Fri, 20 Aug 2021 19:11:58 +0100 Subject: [PATCH 2/2] save --- src/app/pages/chat/chat.page.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index d83e749cd..4e266526d 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -434,7 +434,6 @@ hideRefreshButton(){ } async getGroups(){ - this.showLoader = true; this.result = this.chatService.getAllPrivateGroups().subscribe(async (res:any)=>{ if(res.groups != 200){ @@ -449,7 +448,6 @@ hideRefreshButton(){ return dateB - dateA; }); console.log(this.allGroups); - this.showLoader = false; /* }); */ if(this.route.url != "/home/chat"){ console.log("Timer message stop")