Make page title dynamic, better notification handling.
This commit is contained in:
parent
d0281f5341
commit
963a0035e5
4 changed files with 38 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
import { sortBy, take } from 'lodash'
|
||||
import { sortBy, take, filter } from 'lodash'
|
||||
|
||||
const Notifications = {
|
||||
data () {
|
||||
|
@ -7,8 +7,30 @@ const Notifications = {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
notifications () {
|
||||
return this.$store.state.statuses.notifications
|
||||
},
|
||||
unseenNotifications () {
|
||||
return filter(this.notifications, ({seen}) => !seen)
|
||||
},
|
||||
visibleNotifications () {
|
||||
return take(sortBy(this.$store.state.statuses.notifications, ({action}) => -action.id), this.visibleNotificationCount)
|
||||
// Don't know why, but sortBy([seen, -action.id]) doesn't work.
|
||||
let sortedNotifications = sortBy(this.notifications, ({action}) => -action.id)
|
||||
sortedNotifications = sortBy(sortedNotifications, 'seen')
|
||||
return take(sortedNotifications, this.visibleNotificationCount)
|
||||
},
|
||||
unseenCount () {
|
||||
return this.unseenNotifications.length
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
unseenCount (count) {
|
||||
this.$store.dispatch('setPageTitle', `(${count})`)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
markAsSeen () {
|
||||
this.$store.commit('markNotificationsAsSeen', this.visibleNotifications)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue