aboutsummaryrefslogtreecommitdiff
path: root/src/components/notifications/notifications.js
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-02-20 18:58:18 +0100
committerRoger Braun <roger@rogerbraun.net>2017-02-20 18:58:18 +0100
commit5d8b2eb8b57efa36f9bde45fbbffc2e19f675eb4 (patch)
treef7883fdbe27a2cfd81ff72437450976cc243d2f2 /src/components/notifications/notifications.js
parent9d0d1f7de1e37cb40d7ecd34fd93744f55142e2b (diff)
parent73afa8e075cd8e97b09526e2393b0aafc9c8e4e5 (diff)
Merge branch 'develop' into feature/hash-routed
Diffstat (limited to 'src/components/notifications/notifications.js')
-rw-r--r--src/components/notifications/notifications.js32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index 10f987a8..c8d5e212 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -1,14 +1,40 @@
-import { sortBy, take } from 'lodash'
+import { sortBy, take, filter } from 'lodash'
const Notifications = {
data () {
return {
- visibleNotificationCount: 20
+ visibleNotificationCount: 10
}
},
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) {
+ if (count > 0) {
+ this.$store.dispatch('setPageTitle', `(${count})`)
+ } else {
+ this.$store.dispatch('setPageTitle', '')
+ }
+ }
+ },
+ methods: {
+ markAsSeen () {
+ this.$store.commit('markNotificationsAsSeen', this.visibleNotifications)
}
}
}