aboutsummaryrefslogtreecommitdiff
path: root/src/components/notifications/notifications.js
diff options
context:
space:
mode:
authorshpuld <shpuld@gmail.com>2017-02-18 22:37:48 +0200
committershpuld <shpuld@gmail.com>2017-02-18 22:37:48 +0200
commite6f91badfbab71ed8c924bd49a86715852886ff1 (patch)
tree176ac77d5dfb9c3cd08cb3c56412d5d1e9a18835 /src/components/notifications/notifications.js
parentbe2b90df1d3b3369d451476293749bf5d6b1457d (diff)
parentf7a38eb02175e92b2c2029c88e87d877157ffcab (diff)
Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma-fe into develop
Diffstat (limited to 'src/components/notifications/notifications.js')
-rw-r--r--src/components/notifications/notifications.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index 10f987a8..7dbbf588 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -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)
}
}
}