This commit is contained in:
Peter Maquiran
2021-08-19 13:00:20 +01:00
parent 469717cd3f
commit e08a0a2388
+26 -28
View File
@@ -51,8 +51,6 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.connection.callback = this.load
/* this.dm = this.navParams.get('dm'); */
}
ngOnChanges(changes: SimpleChanges): void {
@@ -300,36 +298,36 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
return await modal.present();
}
async serverLongPull() {
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')
}
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 {
// Got message
//let message = await response.text();
//this.loadMessages()
//await this.serverLongPull();
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();
}
});
}
}