Show badges for unread announcements
This commit is contained in:
parent
fe1d01ec9a
commit
b4a7e58bec
|
@ -54,7 +54,7 @@ const MobileNav = {
|
||||||
isChat () {
|
isChat () {
|
||||||
return this.$route.name === 'chat'
|
return this.$route.name === 'chat'
|
||||||
},
|
},
|
||||||
...mapGetters(['unreadChatCount']),
|
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount']),
|
||||||
chatsPinned () {
|
chatsPinned () {
|
||||||
return new Set(this.$store.state.serverSideStorage.prefsStorage.collections.pinnedNavItems).has('chats')
|
return new Set(this.$store.state.serverSideStorage.prefsStorage.collections.pinnedNavItems).has('chats')
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
icon="bars"
|
icon="bars"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="unreadChatCount && !chatsPinned"
|
v-if="(unreadChatCount && !chatsPinned) || unreadAnnouncementCount"
|
||||||
class="alert-dot"
|
class="alert-dot"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -117,7 +117,7 @@ const NavPanel = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
...mapGetters(['unreadChatCount'])
|
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ export const ROOT_ITEMS = {
|
||||||
announcements: {
|
announcements: {
|
||||||
route: 'announcements',
|
route: 'announcements',
|
||||||
icon: 'bullhorn',
|
icon: 'bullhorn',
|
||||||
label: 'nav.announcements'
|
label: 'nav.announcements',
|
||||||
|
badgeGetter: 'unreadAnnouncementCount'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ const Notifications = {
|
||||||
return this.unseenNotifications.length
|
return this.unseenNotifications.length
|
||||||
},
|
},
|
||||||
unseenCountTitle () {
|
unseenCountTitle () {
|
||||||
return this.unseenCount + (this.unreadChatCount)
|
return this.unseenCount + (this.unreadChatCount) + this.unreadAnnouncementCount
|
||||||
},
|
},
|
||||||
loading () {
|
loading () {
|
||||||
return this.$store.state.statuses.notifications.loading
|
return this.$store.state.statuses.notifications.loading
|
||||||
|
@ -94,7 +94,7 @@ const Notifications = {
|
||||||
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
|
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
|
||||||
},
|
},
|
||||||
noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders },
|
noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders },
|
||||||
...mapGetters(['unreadChatCount'])
|
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.scrollerRef = this.$refs.root.closest('.column.-scrollable')
|
this.scrollerRef = this.$refs.root.closest('.column.-scrollable')
|
||||||
|
|
|
@ -97,7 +97,7 @@ const SideDrawer = {
|
||||||
...mapState({
|
...mapState({
|
||||||
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
|
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
|
||||||
}),
|
}),
|
||||||
...mapGetters(['unreadChatCount'])
|
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleDrawer () {
|
toggleDrawer () {
|
||||||
|
|
|
@ -202,6 +202,12 @@
|
||||||
class="fa-scale-110 fa-old-padding"
|
class="fa-scale-110 fa-old-padding"
|
||||||
icon="bullhorn"
|
icon="bullhorn"
|
||||||
/> {{ $t("nav.announcements") }}
|
/> {{ $t("nav.announcements") }}
|
||||||
|
<span
|
||||||
|
v-if="unreadAnnouncementCount"
|
||||||
|
class="badge badge-notification"
|
||||||
|
>
|
||||||
|
{{ unreadAnnouncementCount }}
|
||||||
|
</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
|
|
|
@ -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 = {
|
const announcements = {
|
||||||
state: defaultState,
|
state: defaultState,
|
||||||
mutations,
|
mutations,
|
||||||
|
getters,
|
||||||
actions: {
|
actions: {
|
||||||
fetchAnnouncements (store) {
|
fetchAnnouncements (store) {
|
||||||
const currentUser = store.rootState.users.currentUser
|
const currentUser = store.rootState.users.currentUser
|
||||||
|
|
Loading…
Reference in New Issue