show already selected members of the group chat

- filter list of available members to group chat
This commit is contained in:
tiago.kayaya
2021-01-26 11:03:00 +01:00
parent c1494c70a7
commit 0ef5b6628a
8 changed files with 58 additions and 31 deletions
@@ -1,6 +1,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams } from '@ionic/angular';
import * as _ from 'lodash';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { NewGroupPage } from '../../new-group/new-group.page';
@@ -24,6 +25,7 @@ export class GroupContactsPage implements OnInit {
contacts: any;
textSearch:string;
room:any;
members:any;
dm:any;
isGroupCreated:boolean;
groupName:string;
@@ -46,6 +48,7 @@ export class GroupContactsPage implements OnInit {
this.isGroupCreated = this.navParams.get('isCreated');
this.groupName = this.navParams.get('name');
this.room = this.navParams.get('room');
this.members = this.navParams.get('members');
}
ngOnInit() {
@@ -59,21 +62,7 @@ export class GroupContactsPage implements OnInit {
headers: this.headers,
};
this.chatService.getAllUsers().subscribe((res:any)=>{
console.log(res.users);
res.users.forEach(user =>{
let usr = {
"_id": user._id,
"username": user.username,
"name":user.name,
"isChecked": false,
}
if(this.listContacts == null){
this.listContacts = new Array();
}
this.listContacts.push(usr);
});
this.contacts = this.listContacts.filter(data => data.username != this.loggedUser.me.username);
this.contacts = res.users.filter(f => !this.members.some(item => item._id === f._id));
this.users = this.contacts.sort((a,b) => {
if(a.name < b.name){
return -1;