diff --git a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts index c1fdc3618..fad0eb6ee 100644 --- a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts +++ b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts @@ -1,5 +1,5 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import * as _ from 'lodash'; import { AuthService } from 'src/app/services/auth.service'; @@ -31,12 +31,14 @@ export class GroupContactsPage implements OnInit { groupName:string; selectedUserList:any; + @Input() roomId:string; + constructor( private modalController: ModalController, private http: HttpClient, private chatService: ChatService, private authService: AuthService, - private navParams: NavParams, + //private navParams: NavParams, ) { this.authService.userData$.subscribe((res:any)=>{ @@ -45,18 +47,31 @@ export class GroupContactsPage implements OnInit { this.textSearch=""; this.dm=null; this.room=null; - this.isGroupCreated = this.navParams.get('isCreated'); + /* this.isGroupCreated = this.navParams.get('isCreated'); this.groupName = this.navParams.get('name'); this.room = this.navParams.get('room'); - this.members = this.navParams.get('members'); + this.members = this.navParams.get('members'); */ } ngOnInit() { + this.getRoomInfo(); this.loadUsers(); console.log(this.groupName); console.log(this.isGroupCreated); } + getRoomInfo(){ + this.showLoader = true; + this.chatService.getRoomInfo(this.roomId).subscribe(room=>{ + this.room = room['room']; + this.groupName = this.room.name.split('-').join(' '); + /* this.roomName = this.room.name.split('-').join(' '); + this.getGroupContacts(this.room); + this.loadGroupMessages(this.room); */ + this.showLoader = false; + }); + } + loadUsers(){ this.options = { headers: this.headers, @@ -156,8 +171,8 @@ export class GroupContactsPage implements OnInit { } createGroup(){ + console.log(this.groupName); if(!this.isGroupCreated){ - /* this.close(); */ let body = { "name":this.groupName, } this.chatService.addGroup(body).subscribe(res=>{ console.log('group created'); @@ -170,15 +185,7 @@ export class GroupContactsPage implements OnInit { } else{ this.addContacts(this.room); - this.close(); - /* this.openGroupMessages(this.room); */ - /* this.chatService.getGroupInfo(this.room._id).subscribe(res=>{ - console.log(res); - - this.addContacts(res['group']); - this.openGroupMessages(res['group']); - }) */ - + this.close(); } }