This commit is contained in:
tiago.kayaya
2021-03-17 09:06:42 +01:00
parent b667fad2a3
commit 41d9c2b5b6
6 changed files with 28 additions and 22 deletions
@@ -8,7 +8,7 @@
<div class="div-title">
<ion-label class="title">Contactos</ion-label>
</div>
<app-btn-seguinte (click)="createGroup()"></app-btn-seguinte>
<app-btn-seguinte (click)="updateGroup()"></app-btn-seguinte>
</div>
</div>
</ion-toolbar>
@@ -1,5 +1,5 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ModalController, NavParams } from '@ionic/angular';
import * as _ from 'lodash';
import { AuthService } from 'src/app/services/auth.service';
@@ -32,6 +32,7 @@ export class GroupContactsPage implements OnInit {
selectedUserList:any;
@Input() roomId:string;
@Output() openGroupMessage:EventEmitter<any> = new EventEmitter<any>();
constructor(
private modalController: ModalController,
@@ -54,21 +55,19 @@ export class GroupContactsPage implements OnInit {
}
ngOnInit() {
this.getRoomInfo();
//this.getRoomInfo();
this.loadUsers();
console.log(this.groupName);
console.log(this.isGroupCreated);
console.log(this.roomId);
//console.log(this.isGroupCreated);
}
getRoomInfo(){
updateGroup(){
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.addContacts(this.room);
this.showLoader = false;
this.openGroupMessage.emit(this.room._id)
});
}
@@ -162,7 +161,6 @@ export class GroupContactsPage implements OnInit {
let body ={
"roomId":room._id,
"userId":user._id,
}
this.chatService.addUserToGroup(body).subscribe(res=>{
console.log(res['success']);
@@ -170,7 +168,7 @@ export class GroupContactsPage implements OnInit {
});
}
createGroup(){
/* createGroup(){
console.log(this.groupName);
if(!this.isGroupCreated){
let body = { "name":this.groupName, }
@@ -187,7 +185,7 @@ export class GroupContactsPage implements OnInit {
this.addContacts(this.room);
this.close();
}
}
} */
async newGroup(){
this.close();
@@ -19,7 +19,7 @@ export class NewGroupPage implements OnInit {
//groupName:string;
@Input() groupName:string;
@Output() closeAllDesktopComponent = new EventEmitter<any>();
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
constructor(
private pickerController: PickerController,
@@ -42,7 +42,7 @@ export class NewGroupPage implements OnInit {
close(){
//this.modalController.dismiss();
console.log('close');
this.closeAllDesktopComponent.emit();
this.addGroupMessage.emit();
}
createGroup(){
@@ -51,7 +51,7 @@ export class NewGroupPage implements OnInit {
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
this.closeAllDesktopComponent.emit(res['group']._id);
this.addGroupMessage.emit(res['group']._id);
});
}