Show badges for unread announcements

This commit is contained in:
Tusooa Zhu 2022-03-17 17:51:39 -04:00
parent 60e2912005
commit bb2940d541
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
8 changed files with 27 additions and 6 deletions

View File

@ -47,7 +47,7 @@ const MobileNav = {
isChat () {
return this.$route.name === 'chat'
},
...mapGetters(['unreadChatCount'])
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
},
methods: {
toggleMobileSidebar () {

View File

@ -18,7 +18,7 @@
icon="bars"
/>
<div
v-if="unreadChatCount"
v-if="unreadChatCount || unreadAnnouncementCount"
class="alert-dot"
/>
</button>

View File

@ -57,7 +57,7 @@ const NavPanel = {
federating: state => state.instance.federating,
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
}),
...mapGetters(['unreadChatCount'])
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
}
}

View File

@ -95,6 +95,12 @@
class="fa-scale-110"
icon="bullhorn"
/>{{ $t('nav.announcements') }}
<span
v-if="unreadAnnouncementCount > 0"
class="badge badge-notification"
>
{{ unreadAnnouncementCount }}
</span>
</router-link>
</li>
</ul>

View File

@ -60,7 +60,7 @@ const Notifications = {
return this.unseenNotifications.length
},
unseenCountTitle () {
return this.unseenCount + (this.unreadChatCount)
return this.unseenCount + (this.unreadChatCount) + this.unreadAnnouncementCount
},
loading () {
return this.$store.state.statuses.notifications.loading
@ -68,7 +68,7 @@ const Notifications = {
notificationsToDisplay () {
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
},
...mapGetters(['unreadChatCount'])
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
},
watch: {
unseenCountTitle (count) {

View File

@ -86,7 +86,7 @@ const SideDrawer = {
...mapState({
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
}),
...mapGetters(['unreadChatCount'])
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
},
methods: {
toggleDrawer () {

View File

@ -190,6 +190,12 @@
class="fa-scale-110 fa-old-padding"
icon="bullhorn"
/> {{ $t("nav.announcements") }}
<span
v-if="unreadAnnouncementCount"
class="badge badge-notification"
>
{{ unreadAnnouncementCount }}
</span>
</router-link>
</li>
<li

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