Skip to content

Commit a4af5ef

Browse files
committed
(fix) immediate newMessages watcher
1 parent 453bacc commit a4af5ef

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/ChatWindow/Message/Message.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,17 @@ export default {
286286
},
287287
288288
watch: {
289-
newMessages(val) {
290-
if (!val.length || !this.showNewMessagesDivider) {
291-
return (this.newMessage = {})
289+
newMessages: {
290+
immediate: true,
291+
handler(val) {
292+
if (!val.length || !this.showNewMessagesDivider) {
293+
return (this.newMessage = {})
294+
}
295+
296+
this.newMessage = val.reduce((res, obj) =>
297+
obj.index < res.index ? obj : res
298+
)
292299
}
293-
294-
this.newMessage = val.reduce((res, obj) =>
295-
obj.index < res.index ? obj : res
296-
)
297300
}
298301
},
299302

0 commit comments

Comments
 (0)