Show badges for unread announcements

This commit is contained in:
Tusooa Zhu 2022-03-17 17:51:39 -04:00 committed by tusooa
commit b4a7e58bec
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
8 changed files with 23 additions and 7 deletions

View file

@ -25,9 +25,18 @@ export const mutations = {
}
}
export const getters = {
unreadAnnouncementCount (state) {
return state.announcements.reduce((acc, cur) => {
return (!cur.inactive && !cur.read) ? acc + 1 : acc
}, 0)
}
}
const announcements = {
state: defaultState,
mutations,
getters,
actions: {
fetchAnnouncements (store) {
const currentUser = store.rootState.users.currentUser