add skeleton to chat list

This commit is contained in:
tiago.kayaya
2021-12-17 16:54:18 +01:00
parent d992f546ef
commit 9a8be67bd1
4 changed files with 49 additions and 25 deletions
+9 -23
View File
@@ -131,7 +131,7 @@ export class ChatPage implements OnInit {
this.modalController.dismiss();
}
};
this.showLoader = true;
}
ngOnInit() {
@@ -178,6 +178,10 @@ export class ChatPage implements OnInit {
});
}
numSequence(n: number): Array<number> {
return Array(n);
}
ngOnDestroy() {
this.setStatus('offline');
this.dataService.set("newGroup", false);
@@ -386,10 +390,12 @@ export class ChatPage implements OnInit {
load() {
switch (this.segment) {
case "Contactos":
this.showLoader = true;
this.getDirectMessages();
break;
case "Grupos":
this.showLoader = true;
this.getGroups();
break;
}
@@ -483,14 +489,10 @@ 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) {
@@ -501,13 +503,6 @@ export class ChatPage implements OnInit {
return dateB - dateA;
});
}
//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")
@@ -522,7 +517,6 @@ export class ChatPage implements OnInit {
}
else {
//console.log('No timer!');
}
}
}
@@ -555,19 +549,14 @@ export class ChatPage implements OnInit {
async getGroups(event?) {
this.result = this.chatService.getAllPrivateGroups().subscribe(async (res: any) => {
//console.log(res);
this.showLoader = false;
if (res.groups != 200) {
this.privateGroups = res.groups;
/* this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{
this.publicGroups = res.channels; */
//let all = this.privateGroups.concat(this.publicGroups);
this.allGroups = this.privateGroups.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
});
//console.log(this.allGroups);
/* }); */
if (this.route.url != "/home/chat") {
console.log("Timer message stop")
}
@@ -576,15 +565,12 @@ export class ChatPage implements OnInit {
if (this.segment == "Grupos" && this.showGroupMessages != true) {
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getGroups();
//console.log('Timer groups list running')
}
}
}
else {
await this.getGroups();
}
});
}