diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 8e52e0f70..10e256568 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -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(); + } + }); } }