fix chat open modal

This commit is contained in:
Lorito Tiago
2023-10-19 15:03:12 +01:00
parent 2a4796bb3d
commit 26b894ed1c
11 changed files with 976 additions and 831 deletions
+46 -7
View File
@@ -30,7 +30,7 @@ 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 { RouteService } from 'src/app/services/route.service';
import { Plugins } from '@capacitor/core';
const { App } = Plugins;
@@ -126,7 +126,8 @@ export class ChatPage implements OnInit {
private activatedRoute: ActivatedRoute,
private eventTriger: EventTrigger,
private RochetChatConnectorService: RochetChatConnectorService,
private zone: NgZone
private zone: NgZone,
public RouteService: RouteService,
) {
this.headers = new HttpHeaders();
@@ -174,7 +175,6 @@ export class ChatPage implements OnInit {
}
});
this.routeCheck()
}
ngOnDestroy() {
@@ -189,14 +189,45 @@ export class ChatPage implements OnInit {
// Retry connecting or other reconnection logic can be added here.
}
routeCheck() {
firstEnter = true
routeCheck() {
const urlParams = new URLSearchParams(window.location.search);
const roomId = urlParams.get('roomId');
if (roomId) {
const room = this.ChatSystemService.getRoomById(roomId);
if (this.firstEnter) {
this.firstEnter = false
let delay = this.RouteService.history.find((item) => {
return ['/home/publications', '/home/agenda', '/home/gabinete', '/home/events'].filter(x => {
return item.includes(x)
}).length >= 1
})
if (!delay) {
console.log("delay")
setTimeout(() => {
this.openChat(roomId)
}, 2000)
} else {
console.log("no dalay")
this.openChat(roomId)
}
} else {
this.openChat(roomId)
}
}
}
openFailed = 0
openChat(roomId) {
const room = this.ChatSystemService.getRoomById(roomId);
if (room) {
this.openFailed = 0
if (room.isGroup) {
this.segment = 'Grupos'
this.openGroupMessagesPage(roomId)
@@ -204,8 +235,17 @@ export class ChatPage implements OnInit {
this.segment = 'Contactos'
this.openMessagesPage(roomId)
}
}
} else {
if (this.openFailed <= 3) {
this.openFailed++
setTimeout(() => {
this.openChat(roomId)
}, 1000)
} else {
this.openFailed = 0
}
}
}
@@ -751,7 +791,6 @@ export class ChatPage implements OnInit {
});
modal.onDidDismiss().then((Data) => {
// console.log(Data,'daatatatat');
// let data = Data.data
// let roomId = data.roomId