mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
further improvements
This commit is contained in:
@@ -139,6 +139,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.scrollingOnce = false;
|
||||
}
|
||||
this.currentPosition = scroll;
|
||||
/* console.log(this.currentPosition);
|
||||
console.log(this.scrollingOnce); */
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -356,6 +358,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
this.openNewEventPage.emit(data);
|
||||
}
|
||||
else if(res['data'] == 'take-picture'){
|
||||
this.fileService.addCameraPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-picture'){
|
||||
this.fileService.addPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
@@ -376,38 +382,42 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
async serverLongPull() {
|
||||
|
||||
const roomId = this.roomId
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||
const roomId = this.roomId;
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.serverLongPull();
|
||||
} else if (res != 200) {
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||
console.log(res['success']);
|
||||
|
||||
|
||||
if (res['success'] == true) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
//this.loadMessages()
|
||||
this.messages = res['messages'].reverse();
|
||||
this.chatMessageStore.add(roomId, this.messages)
|
||||
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
if(this.route.url != "/home/chat"){
|
||||
console.log("Timer message stop")
|
||||
} else {
|
||||
if(document.querySelector('app-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
await this.serverLongPull();
|
||||
this.getDirectMessages.emit();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else{
|
||||
if(document.querySelector('app-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
await this.serverLongPull();
|
||||
this.getDirectMessages.emit();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
}
|
||||
} /* else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
} */
|
||||
}, (error)=>{
|
||||
console.log(error);
|
||||
this.serverLongPull();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user