From 9deac64c2421004ae9254ec1bbbfaef5919b793f Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 26 Dec 2020 01:26:20 +0900
Subject: [PATCH] refs #2014 Display only predefined notification type in
notifications
---
.../TimelineSpace/Contents/Notifications.vue | 25 +++++++++++--------
.../TimelineSpace/Contents/Notifications.ts | 23 +++++++++++++++--
2 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Contents/Notifications.vue b/src/renderer/components/TimelineSpace/Contents/Notifications.vue
index 906c852a..5370c3c9 100644
--- a/src/renderer/components/TimelineSpace/Contents/Notifications.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Notifications.vue
@@ -2,7 +2,7 @@
{{ unread.length > 0 ? unread.length : '' }}
-
+
state.TimelineSpace.Contents.SideBar.openSideBar,
startReload: state => state.TimelineSpace.HeaderMenu.reload,
backgroundColor: state => state.App.theme.background_color,
- notifications: state => state.TimelineSpace.Contents.Notifications.notifications,
lazyLoading: state => state.TimelineSpace.Contents.Notifications.lazyLoading,
heading: state => state.TimelineSpace.Contents.Notifications.heading,
unread: state => state.TimelineSpace.Contents.Notifications.unreadNotifications,
filter: state => state.TimelineSpace.Contents.Notifications.filter
}),
+ ...mapGetters('TimelineSpace/Contents/Notifications', ['handledNotifications']),
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
shortcutEnabled: function () {
if (this.modalOpened) {
@@ -63,7 +63,7 @@ export default {
return true
}
// Sometimes notifications are deleted, so perhaps focused notification don't exist.
- const currentIndex = this.notifications.findIndex(notification => this.focusedId === notification.id)
+ const currentIndex = this.handledNotifications.findIndex(notification => this.focusedId === notification.id)
return currentIndex === -1
}
},
@@ -123,7 +123,10 @@ export default {
!this.lazyloading
) {
this.$store
- .dispatch('TimelineSpace/Contents/Notifications/lazyFetchNotifications', this.notifications[this.notifications.length - 1])
+ .dispatch(
+ 'TimelineSpace/Contents/Notifications/lazyFetchNotifications',
+ this.handledNotifications[this.handledNotifications.length - 1]
+ )
.catch(() => {
this.$message({
message: this.$t('message.notification_fetch_error'),
@@ -157,19 +160,19 @@ export default {
this.focusedId = null
},
focusNext() {
- const currentIndex = this.notifications.findIndex(notification => this.focusedId === notification.id)
+ const currentIndex = this.handledNotifications.findIndex(notification => this.focusedId === notification.id)
if (currentIndex === -1) {
- this.focusedId = this.notifications[0].id
- } else if (currentIndex < this.notifications.length) {
- this.focusedId = this.notifications[currentIndex + 1].id
+ this.focusedId = this.handledNotifications[0].id
+ } else if (currentIndex < this.handledNotifications.length) {
+ this.focusedId = this.handledNotifications[currentIndex + 1].id
}
},
focusPrev() {
- const currentIndex = this.notifications.findIndex(notification => this.focusedId === notification.id)
+ const currentIndex = this.handledNotifications.findIndex(notification => this.focusedId === notification.id)
if (currentIndex === 0) {
this.focusedId = null
} else if (currentIndex > 0) {
- this.focusedId = this.notifications[currentIndex - 1].id
+ this.focusedId = this.handledNotifications[currentIndex - 1].id
}
},
focusNotification(notification) {
@@ -181,7 +184,7 @@ export default {
handleKey(event) {
switch (event.srcKey) {
case 'next':
- this.focusedId = this.notifications[0].id
+ this.focusedId = this.handledNotifications[0].id
break
}
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Notifications.ts b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
index b4f4e0fc..1200fc33 100644
--- a/src/renderer/store/TimelineSpace/Contents/Notifications.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
@@ -1,5 +1,5 @@
import generator, { Entity } from 'megalodon'
-import { Module, MutationTree, ActionTree } from 'vuex'
+import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
import { RootState } from '@/store'
import { MyWindow } from '~/src/types/global'
@@ -144,11 +144,30 @@ const actions: ActionTree = {
}
}
+const getters: GetterTree = {
+ handledNotifications: state => {
+ return state.notifications.filter(n => {
+ switch (n.type) {
+ case 'favourite':
+ case 'follow':
+ case 'follow_request':
+ case 'mention':
+ case 'reblog':
+ case 'emoji_reaction':
+ return true
+ default:
+ return false
+ }
+ })
+ }
+}
+
const Notifications: Module = {
namespaced: true,
state: state,
mutations: mutations,
- actions: actions
+ actions: actions,
+ getters: getters
}
export default Notifications