From 0767c88c045fb3c8f492c32664ae5182e1790f14 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 23 Jun 2021 17:59:29 +0200 Subject: Only scroll to focussed message once We should scroll as soon as we have the old messages / context loaded. For newer messages, don't scroll up again to the read marker in case there is one. Renamed getMessages for more clarity. Signed-off-by: Vincent Petry --- src/components/MessagesList/MessagesList.vue | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index 65974881a..6aa3c5741 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -459,10 +459,7 @@ export default { }) // get history + new messages - await this.getMessages(true) - } else { - // get only new messages - await this.getMessages(false) + await this.getOldMessages(true) } // focus on next tick to make sure the DOM elements @@ -470,6 +467,9 @@ export default { this.$nextTick(() => { this.scrollToFocussedMessage() }) + + // get new messages + await this.lookForNewMessages() } else { this.$store.dispatch('cancelLookForNewMessages', { requestId: this.chatIdentifier }) } @@ -478,15 +478,8 @@ export default { /** * Fetches the messages of a conversation given the conversation token. Triggers * a long-polling request for new messages. - * @param {boolean} loadOldMessages In case it is the first visit of this conversation, we need to load the history */ - async getMessages(loadOldMessages) { - if (loadOldMessages) { - // Gets the history of the conversation. - await this.getOldMessages(true) - this.scrollToFocussedMessage() - } - + async lookForNewMessages() { // Once the history is received, starts looking for new messages. if (this._isBeingDestroyed || this._isDestroyed) { console.debug('Prevent getting new messages on a destroyed MessagesList') -- cgit v1.2.3