mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
reconnect rocketchat socket
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
Output,
|
||||
NgZone,
|
||||
} from '@angular/core';
|
||||
import { ModalController, Platform } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
@@ -28,8 +29,13 @@ import { StorageService } from 'src/app/services/storage.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||
|
||||
|
||||
import { Plugins } from '@capacitor/core';
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@Component({
|
||||
selector: 'app-chat',
|
||||
templateUrl: './chat.page.html',
|
||||
@@ -115,7 +121,9 @@ export class ChatPage implements OnInit {
|
||||
private storageservice: StorageService,
|
||||
public ChatSystemService: ChatSystemService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private eventTriger: EventTrigger
|
||||
private eventTriger: EventTrigger,
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private zone: NgZone
|
||||
) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
@@ -140,6 +148,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
console.log("Loading TestComponent")
|
||||
this.segment = "Contactos";
|
||||
|
||||
this.authService.userData$.subscribe((res: any) => {
|
||||
@@ -164,6 +173,22 @@ export class ChatPage implements OnInit {
|
||||
});
|
||||
|
||||
this.routeCheck()
|
||||
|
||||
|
||||
if (!this.platform.is('desktop')) {
|
||||
App.addListener('appStateChange', ({ isActive }) => {
|
||||
if (isActive) {
|
||||
// The app is in the foreground.
|
||||
console.log('App is in the foreground');
|
||||
this.RochetChatConnectorService.connect()
|
||||
this.reloadComponent(true)
|
||||
} else {
|
||||
// The app is in the background.
|
||||
console.log('App is in the background');
|
||||
// You can perform actions specific to the background state here.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
routeCheck() {
|
||||
@@ -409,6 +434,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
onSegmentChange() {
|
||||
this.ChatSystemService.getAllRooms();
|
||||
this.ChatSystemService._dm
|
||||
}
|
||||
|
||||
doRefresh(event) {
|
||||
@@ -830,5 +856,18 @@ export class ChatPage implements OnInit {
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
reloadComponent(self:boolean,urlToNavigateTo ?:string){
|
||||
//skipLocationChange:true means dont update the url to / when navigating
|
||||
console.log("Current route I am on:",this.router.url);
|
||||
const url=self ? this.router.url :urlToNavigateTo;
|
||||
this.zone.run(() =>this.router.navigateByUrl('/',{skipLocationChange:true}).then(()=>{
|
||||
this.zone.run(() => this.router.navigate([`/${url}`]).then(()=>{
|
||||
console.log(`After navigation I am on:${this.router.url}`)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user