diff options
| -rw-r--r-- | src/components/mobile_nav/mobile_nav.js | 2 | ||||
| -rw-r--r-- | src/components/mobile_nav/mobile_nav.vue | 2 | ||||
| -rw-r--r-- | src/components/nav_panel/nav_panel.js | 2 | ||||
| -rw-r--r-- | src/components/navigation/navigation.js | 3 | ||||
| -rw-r--r-- | src/components/notifications/notifications.js | 4 | ||||
| -rw-r--r-- | src/components/side_drawer/side_drawer.js | 2 | ||||
| -rw-r--r-- | src/components/side_drawer/side_drawer.vue | 6 | ||||
| -rw-r--r-- | src/modules/announcements.js | 9 |
8 files changed, 23 insertions, 7 deletions
diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js index fb8ffa30..cdbbb812 100644 --- a/src/components/mobile_nav/mobile_nav.js +++ b/src/components/mobile_nav/mobile_nav.js @@ -54,7 +54,7 @@ const MobileNav = { isChat () { return this.$route.name === 'chat' }, - ...mapGetters(['unreadChatCount']), + ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount']), chatsPinned () { return new Set(this.$store.state.serverSideStorage.prefsStorage.collections.pinnedNavItems).has('chats') } diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index d642008b..0f1fe621 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -19,7 +19,7 @@ icon="bars" /> <div - v-if="unreadChatCount && !chatsPinned" + v-if="(unreadChatCount && !chatsPinned) || unreadAnnouncementCount" class="alert-dot" /> </button> diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 66c8a4cd..438615da 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -117,7 +117,7 @@ const NavPanel = { } ) }, - ...mapGetters(['unreadChatCount']) + ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount']) } } diff --git a/src/components/navigation/navigation.js b/src/components/navigation/navigation.js index 4541e60b..40100f97 100644 --- a/src/components/navigation/navigation.js +++ b/src/components/navigation/navigation.js @@ -75,6 +75,7 @@ export const ROOT_ITEMS = { announcements: { route: 'announcements', icon: 'bullhorn', - label: 'nav.announcements' + label: 'nav.announcements', + badgeGetter: 'unreadAnnouncementCount' } } diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index c3acd9e0..dde9c93e 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -69,7 +69,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 @@ -94,7 +94,7 @@ const Notifications = { return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount) }, noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders }, - ...mapGetters(['unreadChatCount']) + ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount']) }, mounted () { this.scrollerRef = this.$refs.root.closest('.column.-scrollable') diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index bb22446b..680216dd 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -97,7 +97,7 @@ const SideDrawer = { ...mapState({ pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable }), - ...mapGetters(['unreadChatCount']) + ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount']) }, methods: { toggleDrawer () { diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index dccb8ab7..4101cb03 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -202,6 +202,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 diff --git a/src/modules/announcements.js b/src/modules/announcements.js index 8470fb2a..f04ba50e 100644 --- a/src/modules/announcements.js +++ b/src/modules/announcements.js @@ -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 |
