load messages

This commit is contained in:
Peter Maquiran
2024-08-15 10:26:20 +01:00
parent ea4ca5c34c
commit 9697290bb7
11 changed files with 102 additions and 73 deletions
+10 -10
View File
@@ -166,12 +166,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
ngOnChanges(changes: SimpleChanges): void {
this.roomData$ = this.roomRepositoryService.getItemByIdLive(this.roomId)
this.getMessages();
this.listenToIncomingMessage();
this.listenToDeleteMessage();
this.listenToUpdateMessage();
this.listenToSendMessage();
this.listenToSendMessage()
this.roomMessage$ = this.messageRepositoryService.getItemsLive(this.roomId)
this.roomMembers$ = this.roomRepositoryService.getRoomMemberByIdLive(this.roomId) as any
@@ -193,17 +195,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async getMessages() {
// dont remove this line
this.messages1[this.roomId] = []
let messages = await this.messageRepositoryService.getItems(this.roomId)
this.messages1[this.roomId] = []
this.messages1[this.roomId] = messages
this.messages1[this.roomId] = this.sortBySentAt(this.messages1[this.roomId])
this.loadAttachment()
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
}, 200)
}
@@ -217,14 +219,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
})
if(result.isOk()) {
message.attachments[0].safeFile = result.value
}
}
}
}
// Sorting function
@@ -818,11 +818,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
message.sentAt = new Date().toISOString()
message.attachments = [{
file: compressedImage.value,
file: compressedImage.value.split(',')[1],
fileName: "foto",
source: MessageAttachmentSource.Device,
fileType: MessageAttachmentFileType.Image,
mimeType: picture.value.format
mimeType: 'image/'+picture.value.format
}]
this.messages1[this.roomId].push(message)