mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Longpull added to mobile
This commit is contained in:
@@ -8,6 +8,7 @@ import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popove
|
||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||
import { NewGroupPage } from '../new-group/new-group.page';
|
||||
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||
import {Router} from '@angular/router'
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
@@ -41,6 +42,7 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
||||
private navParams: NavParams,
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
private route: Router
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
@@ -52,6 +54,7 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
||||
this.loggedUser=this.loggedUserChat;
|
||||
this.getRoomInfo();
|
||||
this.scrollToBottom();
|
||||
this.serverLongPull();
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
@@ -223,4 +226,36 @@ export class GroupMessagesPage implements OnInit, AfterViewChecked {
|
||||
}
|
||||
*/
|
||||
|
||||
async serverLongPull(){
|
||||
this.chatService.getPrivateGroupMessages(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'].filter(data => data.t != 'au');
|
||||
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')
|
||||
}
|
||||
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user