fix create chat

This commit is contained in:
Peter Maquiran
2023-03-31 14:54:03 +01:00
parent e1ac8583f3
commit fc9f39491d
3 changed files with 11 additions and 43 deletions
@@ -42,32 +42,13 @@ export class ContactsPage implements OnInit {
ngOnInit() {
// this.chatService.refreshtoken();
this.loadUsers();
// this.loadUsers();
}
onChange(event){
this.textSearch = event.detail.value;
}
loadUsers(){
this.chatService.getAllUsers().subscribe((res:any) => {
this.contacts = res.users.filter(data => data.username != this.sessionStore.user.UserName);
this.users = this.contacts.sort((a,b) => {
if(a.name < b.name){
return -1;
}
if(a.name > b.name){
return 1;
}
return 0;
});
this.showLoader = false;
}, (error) =>{
// this.chatService.refreshtoken();
});
}
separateLetter(record, recordIndex, records){
if(recordIndex == 0){
@@ -92,14 +73,13 @@ export class ContactsPage implements OnInit {
clicked() {}
createRoom(username:string){
createRoom(username:string) {
let body = {
username: username,
}
this.chatService.createRoom(body).subscribe(async(res) => {
this.room = res['room'];
await this.ChatSystemService.getAllRooms();
this.getDirectMessage(this.room._id);
});
@@ -107,15 +87,8 @@ export class ContactsPage implements OnInit {
getDirectMessage(roomId:any) {
this.openModal(roomId);
this.chatService.getAllDirectMessages().subscribe(res=>{
let result = res['ims'].filter(data => data._id == roomId);
this.dm = result[0];
this.openModal(this.dm._id);
});
}
async openModal(roomId:any){
@@ -133,11 +106,4 @@ export class ContactsPage implements OnInit {
modal.onDidDismiss();
}
async openMessages(username:string){
let dm:any;
this.createRoom(username);
}
}