Skip to content

Commit

Permalink
fixup! fix(MessagesList): show 'scroll to bottom' only if there is an…
Browse files Browse the repository at this point in the history
… actual scroll up, or chat is opened not at the bottom

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Feb 24, 2025
1 parent 7de8569 commit 3f15670
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ export default {
if (token && this.isParticipant && !this.isInLobby) {
// prevent sticky mode before we have loaded anything
this.isInitialisingMessages = true
this.previousScrollTopValue = null
const focusMessageId = this.getMessageIdFromHash()

this.$store.dispatch('setVisualLastReadMessageId', { token, id: this.conversation.lastReadMessage })
Expand Down Expand Up @@ -855,7 +856,12 @@ export default {
if (this.isScrolling) {
clearTimeout(this.endScrollTimeout)
}
this.isScrolling = this.previousScrollTopValue > event.target.scrollTop ? 'up' : 'down'
if (this.previousScrollTopValue === null) {
// Chat is just opened, we do not know direction yet
this.isScrolling = null
} else {
this.isScrolling = this.previousScrollTopValue > event.target.scrollTop ? 'up' : 'down'
}
this.previousScrollTopValue = event.target.scrollTop
this.endScrollTimeout = setTimeout(this.endScroll, 3000)
// handle sticky date
Expand Down Expand Up @@ -908,7 +914,7 @@ export default {
return
}

if (scrollHeight > clientHeight && this.isScrolling === 'up') {
if (scrollHeight > clientHeight && this.isScrolling !== 'down') {
this.setChatScrolledToBottom(false)
}

Expand Down

0 comments on commit 3f15670

Please sign in to comment.