This commit is contained in:
Peter Maquiran
2021-08-19 09:10:38 +01:00
parent 94ec7f2651
commit 724445084a
3 changed files with 61 additions and 9 deletions
+24 -2
View File
@@ -10,6 +10,7 @@ import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/mes
import { ProfileComponent } from '../../headers/header-no-search/profile/profile.page';
import { ContactsPage } from '../new-group/contacts/contacts.page';
import { Router } from '@angular/router';
import { connection } from 'src/app/services/socket/synchro.service';
@Component({
selector: 'app-messages',
@@ -33,6 +34,9 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
@Input() roomId:string;
@Input() showMessages:string;
connection = connection
constructor(
public popoverController: PopoverController,
private modalController: ModalController,
@@ -46,6 +50,21 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.connection.callback = function() {
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
if (res == 502) {
} else if (res != 200) {
this.messages = res['messages'].reverse();
console.log(this.messages);
}
});
}
/* this.dm = this.navParams.get('dm'); */
}
ngOnChanges(changes: SimpleChanges): void {
@@ -103,7 +122,9 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
}
}
sendMessage(){
sendMessage() {
this.connection.$send({})
let body = {
"message":
@@ -292,7 +313,8 @@ 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) {