From 9af0ed4d0d7ea81f77b8c08625550d2c465b91b9 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 5 Oct 2022 10:49:17 +0100 Subject: [PATCH] Improve load history --- src/app/services/chat/room.service.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 26c76e868..d1d6d5c1d 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -745,12 +745,9 @@ export class RoomService { } + const chatHistory: chatHistory = await this.RochetChatConnectorService.loadHistory(this.id, limit) - - await this.RochetChatConnectorService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => { - // console.log('load history', chatHistory) - // - + if(chatHistory?.result?.messages) { const messagesId = this.messages.map((message)=> message._id) for(let message of chatHistory.result.messages.reverse()) { @@ -761,14 +758,16 @@ export class RoomService { } } } - }) - setTimeout(() => { - this.scrollDown() - }, 50) - this.hasLoadHistory = true - this.messageReorder(); + setTimeout(() => { + this.scrollDown() + }, 50) + + this.hasLoadHistory = true + this.messageReorder(); + } + } async messageReorder() {