mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
Merge branch 'feature/chat' of https://bitbucket.org/equilibriumito/gabinete-digital into feature/chat
This commit is contained in:
@@ -106,7 +106,9 @@
|
|||||||
(closeAllDesktopComponents)="closeAllDesktopComponents()"
|
(closeAllDesktopComponents)="closeAllDesktopComponents()"
|
||||||
(showEmptyContainer)="showEmptyContainer()"
|
(showEmptyContainer)="showEmptyContainer()"
|
||||||
[style.display]="showMessages ? 'flex' : 'none'"
|
[style.display]="showMessages ? 'flex' : 'none'"
|
||||||
[roomId]="roomId" #messagecontainer>
|
[roomId]="roomId"
|
||||||
|
[showMessages]="showMessages" #messagecontainer>
|
||||||
|
|
||||||
</app-messages>
|
</app-messages>
|
||||||
<app-contacts
|
<app-contacts
|
||||||
(openMessage)="openMessagesPage($event)"
|
(openMessage)="openMessagesPage($event)"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popove
|
|||||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||||
import { NewGroupPage } from '../new-group/new-group.page';
|
import { NewGroupPage } from '../new-group/new-group.page';
|
||||||
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||||
|
import {Router} from '@angular/router'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-messages',
|
selector: 'app-group-messages',
|
||||||
@@ -41,6 +42,7 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
|||||||
private navParams: NavParams,
|
private navParams: NavParams,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
|
private route: Router
|
||||||
) {
|
) {
|
||||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||||
this.isGroupCreated = true;
|
this.isGroupCreated = true;
|
||||||
@@ -52,6 +54,7 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
|||||||
this.loggedUser=this.loggedUserChat;
|
this.loggedUser=this.loggedUserChat;
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
|
this.serverLongPull();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked() {
|
ngAfterViewChecked() {
|
||||||
@@ -223,4 +226,36 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
async serverLongPull(){
|
||||||
|
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res => {
|
||||||
|
|
||||||
|
if (res == 502) {
|
||||||
|
// Connection timeout
|
||||||
|
// happens when the connection was pending for too long
|
||||||
|
// let's reconnect
|
||||||
|
await this.serverLongPull();
|
||||||
|
} else if (res != 200) {
|
||||||
|
// Show Error
|
||||||
|
//showMessage(response.statusText);
|
||||||
|
//this.loadMessages()
|
||||||
|
this.messages = res['messages'].filter(data => data.t != 'au');
|
||||||
|
console.log(this.messages);
|
||||||
|
// Reconnect in one second
|
||||||
|
if(this.route.url != "/home/chat"){
|
||||||
|
console.log("Timer message stop")
|
||||||
|
} else {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
await this.serverLongPull();
|
||||||
|
console.log('Timer message running')
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Got message
|
||||||
|
//let message = await response.text();
|
||||||
|
//this.loadMessages()
|
||||||
|
await this.serverLongPull();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import {Router} from '@angular/router'
|
||||||
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
||||||
import { Status } from 'src/app/models/chat/status.model';
|
import { Status } from 'src/app/models/chat/status.model';
|
||||||
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
||||||
@@ -37,6 +38,7 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
|||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private route: Router
|
||||||
) {
|
) {
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||||
this.roomId = this.navParams.get('roomId');
|
this.roomId = this.navParams.get('roomId');
|
||||||
@@ -63,7 +65,7 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load(){
|
load(){
|
||||||
this.loadMessages();
|
this.serverLongPull();
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,4 +152,36 @@ async openChatOptions(ev?: any) {
|
|||||||
return await popover.present();
|
return await popover.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async serverLongPull(){
|
||||||
|
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||||
|
|
||||||
|
if (res == 502) {
|
||||||
|
// Connection timeout
|
||||||
|
// happens when the connection was pending for too long
|
||||||
|
// let's reconnect
|
||||||
|
await this.serverLongPull();
|
||||||
|
} else if (res != 200) {
|
||||||
|
// Show Error
|
||||||
|
//showMessage(response.statusText);
|
||||||
|
//this.loadMessages()
|
||||||
|
this.messages = res['messages'].reverse();
|
||||||
|
console.log(this.messages);
|
||||||
|
// Reconnect in one second
|
||||||
|
if(this.route.url != "/home/chat"){
|
||||||
|
console.log("Timer message stop")
|
||||||
|
} else {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
await this.serverLongPull();
|
||||||
|
console.log('Timer message running')
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Got message
|
||||||
|
//let message = await response.text();
|
||||||
|
//this.loadMessages()
|
||||||
|
await this.serverLongPull();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popove
|
|||||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||||
import { NewGroupPage } from '../new-group/new-group.page';
|
import { NewGroupPage } from '../new-group/new-group.page';
|
||||||
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||||
|
import { Router } from '@angular/router'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-messages',
|
selector: 'app-group-messages',
|
||||||
@@ -45,6 +46,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewChecked {
|
|||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private animationController: AnimationController,
|
private animationController: AnimationController,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
|
private route: Router
|
||||||
) {
|
) {
|
||||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||||
this.isGroupCreated = true;
|
this.isGroupCreated = true;
|
||||||
@@ -57,6 +59,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewChecked {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loggedUser=this.loggedUserChat;
|
this.loggedUser=this.loggedUserChat;
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
|
this.serverLongPull();
|
||||||
console.log(this.roomId);
|
console.log(this.roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,5 +370,37 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewChecked {
|
|||||||
return await modal.present();
|
return await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async serverLongPull(){
|
||||||
|
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res => {
|
||||||
|
|
||||||
|
if (res == 502) {
|
||||||
|
// Connection timeout
|
||||||
|
// happens when the connection was pending for too long
|
||||||
|
// let's reconnect
|
||||||
|
await this.serverLongPull();
|
||||||
|
} else if (res != 200) {
|
||||||
|
// Show Error
|
||||||
|
//showMessage(response.statusText);
|
||||||
|
//this.loadMessages()
|
||||||
|
this.messages = res['messages'].filter(data => data.t != 'au');
|
||||||
|
console.log(this.messages);
|
||||||
|
// Reconnect in one second
|
||||||
|
if(this.route.url != "/home/chat"){
|
||||||
|
console.log("Timer message stop")
|
||||||
|
} else {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
await this.serverLongPull();
|
||||||
|
console.log('Timer message running')
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Got message
|
||||||
|
//let message = await response.text();
|
||||||
|
//this.loadMessages()
|
||||||
|
await this.serverLongPull();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
|
|||||||
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
|
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
|
||||||
import { ProfileComponent } from '../../headers/header-no-search/profile/profile.page';
|
import { ProfileComponent } from '../../headers/header-no-search/profile/profile.page';
|
||||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-messages',
|
selector: 'app-messages',
|
||||||
@@ -27,8 +28,10 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
dm:any;
|
dm:any;
|
||||||
userPresence='';
|
userPresence='';
|
||||||
dmUsers:any;
|
dmUsers:any;
|
||||||
|
checktimeOut: boolean;
|
||||||
|
|
||||||
@Input() roomId:string;
|
@Input() roomId:string;
|
||||||
|
@Input() showMessages:string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public popoverController: PopoverController,
|
public popoverController: PopoverController,
|
||||||
@@ -39,6 +42,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
private animationController: AnimationController,
|
private animationController: AnimationController,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private route: Router
|
||||||
) {
|
) {
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||||
|
|
||||||
@@ -58,9 +62,17 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
this.load();
|
this.load();
|
||||||
/* }, 9000); */
|
/* }, 9000); */
|
||||||
console.log(this.roomId);
|
console.log(this.roomId);
|
||||||
|
console.log("Chat route", this.route.url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(){
|
||||||
|
this.checktimeOut = false;
|
||||||
|
console.log('On Destroy')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notImplemented(){
|
notImplemented(){
|
||||||
@@ -68,6 +80,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load(){
|
load(){
|
||||||
|
this.checktimeOut = true;
|
||||||
this.serverLongPull();
|
this.serverLongPull();
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
}
|
}
|
||||||
@@ -294,8 +307,14 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
this.messages = res['messages'].reverse();
|
this.messages = res['messages'].reverse();
|
||||||
console.log(this.messages);
|
console.log(this.messages);
|
||||||
// Reconnect in one second
|
// Reconnect in one second
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
if(this.route.url != "/home/chat"){
|
||||||
|
console.log("Timer message stop")
|
||||||
|
} else {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
await this.serverLongPull();
|
await this.serverLongPull();
|
||||||
|
console.log('Timer message running')
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Got message
|
// Got message
|
||||||
//let message = await response.text();
|
//let message = await response.text();
|
||||||
|
|||||||
Reference in New Issue
Block a user