Skip to content

Commit

Permalink
feat: scroll to bottom when sending a message
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwoodland committed Sep 12, 2022
1 parent a49fdc1 commit 2182998
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/views/chat/conversation/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ export default Vue.extend({
}
return messages.reverse()
},
isLastChatItemAuthor(): boolean {
const lastItem = this.chatItems.at(0)
if (!lastItem || !iridium.connector) {
return false
}
return lastItem.message.from === iridium.connector.id
},
noMore(): boolean {
return (
this.numMessages >=
Expand All @@ -118,8 +125,8 @@ export default Vue.extend({
this.isLockedToBottom = container.scrollTop >= 0
})
this.mutationObserver = new MutationObserver(() => {
if (this.isLockedToBottom) {
container.scrollTop = 0
if (this.isLockedToBottom || this.isLastChatItemAuthor) {
container.scrollTo(0, 0)
}
})
this.mutationObserver.observe(container, {
Expand Down

0 comments on commit 2182998

Please sign in to comment.