Skip to content

Commit

Permalink
fix(MessagesList): check if chats are non-scrollable
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Feb 21, 2025
1 parent df0294b commit ae57db2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ export default {
// scroll to bottom if needed
this.scrollToBottom({ smooth: false })

this.$nextTick(() => {
this.checkChatNotScrollable()
})

if (this.conversation?.type === CONVERSATION.TYPE.NOTE_TO_SELF) {
this.$nextTick(() => {
this.updateTasksCount()
Expand All @@ -320,8 +324,7 @@ export default {
this.$nextTick(() => {
this.checkSticky()
// setting wheel event for non-scrollable chat
const isScrollable = this.$refs.scroller.scrollHeight > this.$refs.scroller.clientHeight
if (!this.isChatBeginningReached && !isScrollable) {
if (!this.isChatBeginningReached && this.checkChatNotScrollable()) {
this.$refs.scroller.addEventListener('wheel', this.handleWheelEvent, { passive: true })
}
})
Expand Down Expand Up @@ -385,6 +388,8 @@ export default {
this.$refs.scroller.scrollTo({
top: this.$refs.scroller.scrollHeight,
})
} else {
this.checkChatNotScrollable()
}
},

Expand Down Expand Up @@ -1188,10 +1193,7 @@ export default {
this.$refs.scroller.scrollTop += this.$refs.scroller.offsetHeight / 4
}

if (this.$refs.scroller && this.$refs.scroller.clientHeight === this.$refs.scroller.scrollHeight) {
// chat is not scrollable
this.setChatScrolledToBottom(true)
}
this.checkChatNotScrollable()

if (highlightAnimation && scrollElement === element) {
// element is visible, highlight it
Expand Down Expand Up @@ -1315,6 +1317,18 @@ export default {
this.chatExtrasStore.setTasksCounters({ tasksCount, tasksDoneCount })
},

checkChatNotScrollable() {
const isNotScrollable = this.$refs.scroller
? this.$refs.scroller.clientHeight === this.$refs.scroller.scrollHeight
: false

if (isNotScrollable && !this.isChatScrolledToBottom) {
this.setChatScrolledToBottom(true)
}

return isNotScrollable
},

handleWheelEvent(event) {
// If messages fit in the viewport and user scrolls up, we need to trigger the loading of older messages
if (event.deltaY < 0) {
Expand Down

0 comments on commit ae57db2

Please sign in to comment.