fix bug in create new room

This commit is contained in:
tiago.kayaya
2022-01-26 16:37:59 +01:00
parent 81632c5296
commit 2ab70edd9d
6 changed files with 117 additions and 39 deletions
@@ -2,7 +2,9 @@ import { analyzeAndValidateNgModules } from '@angular/compiler';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
import { DataService } from 'src/app/services/data.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
@@ -25,6 +27,7 @@ export class NewGroupPage implements OnInit{
//groupName:string;
task:any;
documents: any;
loggedUserChat: any;
@Input() groupName:string;
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
@@ -37,8 +40,11 @@ export class NewGroupPage implements OnInit{
private dataService:DataService,
private processesService: ProcessesService,
private router: Router,
public wsChatMethodsService: WsChatMethodsService,
private authService: AuthService,
)
{
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = false;
//this.groupName = this.navParams.get('name');
}
@@ -86,16 +92,37 @@ export class NewGroupPage implements OnInit{
this.addGroupMessage.emit();
}
createGroup(){
async createGroup(){
let name = this.groupName.split(' ').join('-');
//Take out all special characters in string
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
let customFields = {}
let res:any;
if(this.thedate){
let customFields = {
"countDownDate":this.thedate
}
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
console.log(res);
}
else{
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
console.log(res);
}
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
this.addGroupMessage.emit(res.result.rid);
/* this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
this.addGroupMessage.emit(res['group']._id);
this.addGroupMessage.emit(res['group']._id); */
/* this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
@@ -139,11 +166,11 @@ export class NewGroupPage implements OnInit{
}
this.chatService.sendMessage(body).toPromise();
});
}
} */
});
//});
}
async addContacts(){