Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30.0] fix(chat): disable smooth scroll to bottom #13580

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ChatView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
:aria-label="t('spreed', 'Scroll to bottom')"
:title="t('spreed', 'Scroll to bottom')"
class="scroll-to-bottom__button"
@click="smoothScrollToBottom">
@click="scrollToBottom">
<template #icon>
<ChevronDoubleDown :size="20" />
</template>
Expand Down Expand Up @@ -198,8 +198,8 @@ export default {
this.$store.dispatch('initialiseUpload', { files, token: this.token, uploadId })
},

smoothScrollToBottom() {
EventBus.emit('scroll-chat-to-bottom', { smooth: true, force: true })
scrollToBottom() {
EventBus.emit('scroll-chat-to-bottom', { smooth: false, force: true })
},
},

Expand Down
18 changes: 9 additions & 9 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default {

stopFetchingOldMessages: false,

isScrolling: false,
isScrolling: null,

stickyDate: null,

Expand Down Expand Up @@ -298,7 +298,7 @@ export default {
}

// scroll to bottom if needed
this.scrollToBottom({ smooth: true })
this.scrollToBottom({ smooth: false })

if (this.conversation?.type === CONVERSATION.TYPE.NOTE_TO_SELF) {
this.$nextTick(() => {
Expand Down Expand Up @@ -639,7 +639,7 @@ export default {
if (!isFocused) {
// Safeguard 2: in case the fallback message is not found too
// scroll to bottom
this.scrollToBottom({ force: true })
this.scrollToBottom({ smooth: false, force: true })
} else {
this.$store.dispatch('setVisualLastReadMessageId', {
token: this.token,
Expand Down Expand Up @@ -856,12 +856,13 @@ export default {
})
},

onScroll() {
onScroll(event) {
// handle scrolling status
if (this.isScrolling) {
clearTimeout(this.endScrollTimeout)
}
this.isScrolling = true
this.isScrolling = this.previousScrollTopValue > event.target.scrollTop ? 'up' : 'down'
this.previousScrollTopValue = event.target.scrollTop
this.endScrollTimeout = setTimeout(this.endScroll, 3000)
// handle sticky date
if (this.$refs.scroller.scrollTop === 0) {
Expand Down Expand Up @@ -909,14 +910,13 @@ export default {
if (Math.abs(scrollOffset - clientHeight) < SCROLL_TOLERANCE && !this.hasMoreMessagesToLoad && scrollTop > 0) {
this.setChatScrolledToBottom(true)
this.displayMessagesLoader = false
this.previousScrollTopValue = scrollTop
this.debounceUpdateReadMarkerPosition()
return
}

this.setChatScrolledToBottom(false)

if ((scrollHeight > clientHeight && scrollTop < 800 && scrollTop < this.previousScrollTopValue)
if ((scrollHeight > clientHeight && scrollTop < 800 && this.isScrolling === 'up')
|| skipHeightCheck) {
if (this.loadingOldMessages || this.isChatBeginningReached) {
// already loading, don't do it twice
Expand All @@ -934,12 +934,12 @@ export default {
this.setChatScrolledToBottom(false, { auto: true })
}

this.previousScrollTopValue = this.$refs.scroller.scrollTop
this.debounceUpdateReadMarkerPosition()
},

endScroll() {
this.isScrolling = false
this.debounceHandleScroll.flush?.()
this.isScrolling = null
clearTimeout(this.endScrollTimeout)
},

Expand Down
Loading