diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-06-23 17:59:29 +0200 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-06-24 11:09:48 +0200 |
commit | 0767c88c045fb3c8f492c32664ae5182e1790f14 (patch) | |
tree | a4828689ecb2561831d146126c97ef5c7da69763 | |
parent | 0f88cbf55d53b953895941e7d002f3cd03b45676 (diff) |
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 <vincent@nextcloud.com>
-rw-r--r-- | src/components/MessagesList/MessagesList.vue | 17 |
1 files 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') |