mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
@@ -58,7 +58,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
this.load();
|
||||
/* }, 9000); */
|
||||
console.log(this.roomId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
}
|
||||
|
||||
load(){
|
||||
this.loadMessages();
|
||||
this.serverLongPull();
|
||||
this.getChatMembers();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
}
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
this.loadMessages();
|
||||
});
|
||||
this.message = "";
|
||||
}
|
||||
@@ -111,7 +110,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
console.log(res);
|
||||
this.messages = res['messages'].reverse();
|
||||
console.log(this.messages);
|
||||
this.serverLongPull(res)
|
||||
//this.serverLongPull(res)
|
||||
/* this.chatService.subscribe(this.roomId).then(res => {
|
||||
console.log("Real fake msg", res)
|
||||
}); */
|
||||
@@ -280,27 +279,31 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
return await modal.present();
|
||||
}
|
||||
|
||||
async serverLongPull(res){
|
||||
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(res);
|
||||
await this.serverLongPull();
|
||||
} else if (res != 200) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
this.loadMessages()
|
||||
//this.loadMessages()
|
||||
this.messages = res['messages'].reverse();
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.serverLongPull(res);
|
||||
await this.serverLongPull();
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
this.loadMessages()
|
||||
await this.serverLongPull(res);
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user