diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 4638e3d19..074c036e7 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -8,8 +8,6 @@ import { ComponentRef, ComponentFactory, Output, - AfterViewChecked, - AfterViewInit } from '@angular/core'; import { ModalController, Platform } from '@ionic/angular'; import { AuthService } from 'src/app/services/auth.service'; @@ -40,7 +38,7 @@ import { SqliteService } from 'src/app/services/sqlite.service'; templateUrl: './chat.page.html', styleUrls: ['./chat.page.scss'], }) -export class ChatPage implements OnInit, AfterViewInit { +export class ChatPage implements OnInit { showLoader: boolean; @@ -164,42 +162,25 @@ export class ChatPage implements OnInit, AfterViewInit { this.openNewGroupPage(); } */ - - this.router.events.forEach((event) => { if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) { - alert('Aqui' + this.dataService.get("newGroup")) if (this.dataService.get("newGroup")) { this.openNewGroupPage(); } - /* if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) { - alert(this.dataService.get("newGroup")) + else{ + this.closeAllDesktopComponents(); + this.showEmptyComponent = true; } - else { - if (this.dataService.get("newGroup")) { - this.openNewGroupPage(); - } - } */ } else{ this.dataService.set("newGroup", false); } }); - if (this.dataService.get("newGroup")) { - this.openNewGroupPage(); - } - } - - ngAfterViewInit() { - alert(this.dataService.get("newGroup")) - } - - ngAfterViewChecked(){ - //alert(this.dataService.get("newGroup")) } ngOnDestroy() { this.setStatus('offline'); + this.dataService.set("newGroup", false); console.log('On Destroy') } @@ -513,6 +494,13 @@ export class ChatPage implements OnInit, AfterViewInit { console.log('Chat list', res); if (res != 200) { + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.userDirectMessages = res.ims.sort((a, b) => { + var dateA = new Date(a._updatedAt).getTime(); + var dateB = new Date(b._updatedAt).getTime(); + return dateB - dateA; + }); + } //console.log(res.ims); /* this.userDirectMessages = res.ims.sort((a, b) => { var dateA = new Date(a._updatedAt).getTime(); @@ -557,9 +545,10 @@ export class ChatPage implements OnInit, AfterViewInit { this.chatService.getAllUsers().subscribe(res => { console.log('chatusers', res); this.transformDataUserList(res['users']) - - //this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username); - //console.log(this.dmUsers); + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username); + console.log(this.dmUsers); + } }); } diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index 0f23afe55..1a60e2b39 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -634,13 +634,8 @@ export class ExpedienteDetailPage implements OnInit { } openNewGroupPage() { - console.log(this.fulltask); - this.dataService.set("newGroup", true); - - this.router.navigate(['/home/chat']); - this.dataService.set("newGroup", true); - if (window.innerWidth < 801) { + this.router.navigate(['/home/chat']); this.newGroup(); } else { @@ -648,6 +643,7 @@ export class ExpedienteDetailPage implements OnInit { this.dataService.set("task", this.task); this.dataService.set("newGroupName", this.task.Folio); this.dataService.set("documents", this.fulltask.Documents); + this.router.navigate(['/home/chat']); } } diff --git a/src/app/shared/chat/new-group/new-group.page.ts b/src/app/shared/chat/new-group/new-group.page.ts index d50435ade..96bd41d83 100644 --- a/src/app/shared/chat/new-group/new-group.page.ts +++ b/src/app/shared/chat/new-group/new-group.page.ts @@ -1,5 +1,6 @@ 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 { ChatService } from 'src/app/services/chat.service'; import { DataService } from 'src/app/services/data.service'; @@ -35,22 +36,29 @@ export class NewGroupPage implements OnInit{ private chatService: ChatService, private dataService:DataService, private processesService: ProcessesService, + private router: Router, ) { this.isGroupCreated = false; //this.groupName = this.navParams.get('name'); + alert('New group '+this.dataService.get("newGroup")) } ngOnInit() { - //alert(this.dataService.get("newGroup")) - setTimeout(() => { - //alert(this.dataService.get("newGroup")) - }, 100) - if(this.dataService.get("newGroup") == true){ - this.task = this.dataService.get("task"); - this.groupName = this.task.Folio; - this.documents = this.dataService.get("documents"); - } + this.router.events.forEach((event) => { + if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) { + alert('New group '+this.dataService.get("newGroup")) + if (this.dataService.get("newGroup")) { + this.task = this.dataService.get("task"); + this.groupName = this.task.Folio; + this.documents = this.dataService.get("documents"); + } + } + else{ + this.dataService.set("newGroup", false); + } + }); + console.log(this.task); } @@ -82,6 +90,8 @@ export class NewGroupPage implements OnInit{ 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=>{ console.log('group created');