Skip to content
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
12 changes: 12 additions & 0 deletions src/components/LeftSidebar/ConversationsList/ConversationsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@ export default {

mounted() {
EventBus.$on('routeChange', this.onRouteChange)
EventBus.$on('newMessagePosted', this.onMessagePosted)
},

beforeDestroy() {
EventBus.$off('routeChange', this.onRouteChange)
EventBus.$off('newMessagePosted', this.onMessagePosted)
},

methods: {
onMessagePosted({ token }) {
const conversation = document.getElementById(`conversation_${token}`)
this.$nextTick(() => {
conversation.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
})
})
},
onRouteChange({ from, to }) {
if (from.name === 'conversation') {
leaveConversation(from.params.token)
Expand Down
25 changes: 1 addition & 24 deletions src/components/NewMessageForm/NewMessageForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,7 @@ export default {
},
},

watch: {
token(newValue, oldValue) {
this.isCurrentConversationIsFirstInList()
},
},

mounted() {
this.isCurrentConversationIsFirstInList()

EventBus.$on('uploadStart', this.handleUploadStart)
},

Expand Down Expand Up @@ -271,16 +263,7 @@ export default {
// by the server
this.$store.dispatch('processMessage', response.data.ocs.data)
// Scrolls the conversationlist to conversation
if (!this.conversationIsFirstInList) {
const conversation = document.getElementById(`conversation_${this.token}`)
this.$nextTick(() => {
conversation.scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'nearest',
})
})
}
EventBus.$emit('newMessagePosted', { token: this.token, message: temporaryMessage })
} catch (error) {
let statusCode = null
console.debug(`error while submitting message ${error}`, error)
Expand Down Expand Up @@ -387,12 +370,6 @@ export default {

range.setStartAfter(emojiTextNode)
},

// Check whether the current conversation is the first in the conversations
// list and stores the value in the component's data.
isCurrentConversationIsFirstInList() {
this.conversationIsFirstInList = this.$store.getters.conversationsList.map(conversation => conversation.token).indexOf(this.token) === 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work when you had a favorite and posted in a normal conversation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested in this PR and having a favorite or normal conversation makes no difference.
It just makes sure that whatever room you posted in becomes visible in the left panel.

And when posting in a room that is invisible below the scroll panel, the room gets moved to the top, below favorites, highlighted, and it scrolls to that.

@ma12-co do you know why there was a check for "first room" ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember honestly :/

},
},
}
</script>
Expand Down