mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-12-27 00:41:53 +11:00
Update CommunicationsChat.vue
This commit is contained in:
parent
3d7df1c98a
commit
91386b68c0
1 changed files with 26 additions and 24 deletions
|
@ -1115,32 +1115,34 @@ export default {
|
|||
this.focusInput()
|
||||
},
|
||||
autoScroll(smooth = false) {
|
||||
if (!this.avoidAutoScroll) {
|
||||
try {
|
||||
const lastIndex = this.messages.length - 1
|
||||
const lastMessage = document.querySelector(`#message-${lastIndex}`)
|
||||
if (smooth) {
|
||||
lastMessage.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "nearest",
|
||||
inline: "start"
|
||||
})
|
||||
} else {
|
||||
lastMessage.scrollIntoView()
|
||||
}
|
||||
this.autoScrollRetry = 0
|
||||
} catch (e) {
|
||||
console.log("Could not auto scroll, retrying...")
|
||||
if (this.autoScrollRetry < 20) {
|
||||
setTimeout(() => {
|
||||
this.autoScroll()
|
||||
}, 50)
|
||||
this.autoScrollRetry++
|
||||
} else {
|
||||
console.log("Could not auto scroll, retry limit reached")
|
||||
this.$nextTick(() => {
|
||||
if (!this.avoidAutoScroll) {
|
||||
try {
|
||||
const lastIndex = this.messages.length - 1
|
||||
const lastMessage = document.querySelector(`#message-${lastIndex}`)
|
||||
if (smooth) {
|
||||
lastMessage.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "nearest",
|
||||
inline: "start"
|
||||
})
|
||||
} else {
|
||||
lastMessage.scrollIntoView()
|
||||
}
|
||||
this.autoScrollRetry = 0
|
||||
} catch (e) {
|
||||
console.log("Could not auto scroll, retrying...")
|
||||
if (this.autoScrollRetry < 20) {
|
||||
setTimeout(() => {
|
||||
this.autoScroll()
|
||||
}, 50)
|
||||
this.autoScrollRetry++
|
||||
} else {
|
||||
console.log("Could not auto scroll, retry limit reached")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
getMessages() {
|
||||
this.loadingMessages = true
|
||||
|
|
Loading…
Reference in a new issue