Skip to content

Commit

Permalink
fix(MessagesList): ensure that scrolledToBottom state set only on scr…
Browse files Browse the repository at this point in the history
…oll up

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Feb 18, 2025
1 parent 4c06403 commit b6dcc12
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -934,24 +934,25 @@ export default {
return
}

this.setChatScrolledToBottom(false)
if (this.isScrolling === 'up' && (skipHeightCheck || scrollHeight > clientHeight)) {
this.setChatScrolledToBottom(false, { auto: true })

if ((scrollHeight > clientHeight && scrollTop < 800 && this.isScrolling === 'up')
|| skipHeightCheck) {
if (this.loadingOldMessages || this.isChatBeginningReached) {
// already loading, don't do it twice
return
}
this.displayMessagesLoader = true
await this.getOldMessages(false)
this.displayMessagesLoader = false
if (this.$refs.scroller.scrollHeight !== scrollHeight) {
// scroll to previous position + added height
this.$refs.scroller.scrollTo({
top: scrollTop + (this.$refs.scroller.scrollHeight - scrollHeight),
})
if (scrollTop < 800) {
if (this.loadingOldMessages || this.isChatBeginningReached) {
// already loading, don't do it twice
return
}
this.displayMessagesLoader = true
await this.getOldMessages(false)
this.displayMessagesLoader = false
if (this.$refs.scroller.scrollHeight !== scrollHeight) {
// scroll to previous position + added height
this.$refs.scroller.scrollTo({
top: scrollTop + (this.$refs.scroller.scrollHeight - scrollHeight),
})
}
this.setChatScrolledToBottom(false, { auto: true })
}
this.setChatScrolledToBottom(false, { auto: true })
}

this.debounceUpdateReadMarkerPosition()
Expand Down Expand Up @@ -1328,6 +1329,7 @@ export default {
return
}

this.isScrolling = 'up'
this.debounceHandleScroll({ skipHeightCheck: true })
}
},
Expand Down

0 comments on commit b6dcc12

Please sign in to comment.