Skip to content

Commit 22b869c

Browse files
committed
(fix) init bottom scroll on Safari
1 parent 54a19bf commit 22b869c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/ChatWindow/Room/Room.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,12 @@ export default {
449449
450450
watch: {
451451
loadingMessages(val) {
452-
if (val) this.infiniteState = null
453-
else this.focusTextarea(true)
452+
if (val) {
453+
this.infiniteState = null
454+
} else {
455+
if (this.infiniteState) this.infiniteState.loaded()
456+
this.focusTextarea(true)
457+
}
454458
},
455459
room(newVal, oldVal) {
456460
if (newVal.roomId && newVal.roomId !== oldVal.roomId) {
@@ -543,18 +547,18 @@ export default {
543547
const element = this.$refs.scrollContainer
544548
if (!element) return
545549
550+
unwatch()
551+
546552
setTimeout(() => {
547553
element.scrollTo({ top: element.scrollHeight })
548-
unwatch()
549-
}, 0)
554+
this.loadingMessages = false
555+
})
550556
}
551557
)
552558
},
553559
onMessageAdded({ message, index }) {
554560
this.newMessages = []
555561
556-
this.loadingMessages = false
557-
558562
if (index !== this.messages.length - 1) return
559563
560564
setTimeout(() => {
@@ -800,6 +804,11 @@ export default {
800804
this.resetMessage(true)
801805
},
802806
loadMoreMessages(infiniteState) {
807+
if (this.loadingMessages) {
808+
this.infiniteState = infiniteState
809+
return
810+
}
811+
803812
setTimeout(
804813
() => {
805814
if (this.loadingMoreMessages) return

0 commit comments

Comments
 (0)