feat: emit new event "talk:unread:updated" when number of unread messages changes

Signed-off-by: Markus Stoll <markus.stoll@junidas.de>
This commit is contained in:
Markus Stoll
2025-04-11 20:51:20 +02:00
parent 6408ead1d9
commit aca814a0da

View File

@ -95,6 +95,33 @@ export default {
},
computed: {
unreadCountsMap() {
return this.$store.getters.conversationsList.reduce((acc, conversation) => {
if (conversation.isArchived) {
// Do not consider archived conversations in counting
return acc
}
if (conversation.unreadMessages > 0) {
acc.conversations++
acc.messages += conversation.unreadMessages
}
if (conversation.unreadMention) {
acc.mentions++
}
if (conversation.unreadMentionDirect) {
acc.mentionsDirect++
}
return acc
}, {
conversations: 0,
messages: 0,
mentions: 0,
mentionsDirect: 0,
})
},
getUserId() {
return this.$store.getters.getUserId()
},
@ -163,6 +190,14 @@ export default {
}
}
},
unreadCountsMap: {
deep: true,
immediate: true,
handler(value) {
emit('talk:unread:updated', value)
},
}
},
beforeCreate() {