Skip to content

Commit

Permalink
(fix) immediate newMessages watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine92190 committed Mar 17, 2021
1 parent 453bacc commit a4af5ef
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/ChatWindow/Message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,17 @@ export default {
},
watch: {
newMessages(val) {
if (!val.length || !this.showNewMessagesDivider) {
return (this.newMessage = {})
newMessages: {
immediate: true,
handler(val) {
if (!val.length || !this.showNewMessagesDivider) {
return (this.newMessage = {})
}
this.newMessage = val.reduce((res, obj) =>
obj.index < res.index ? obj : res
)
}
this.newMessage = val.reduce((res, obj) =>
obj.index < res.index ? obj : res
)
}
},
Expand Down

0 comments on commit a4af5ef

Please sign in to comment.