refs #2014 Display only predefined notification type in notifications
This commit is contained in:
parent
f37deb8212
commit
9deac64c24
|
@ -2,7 +2,7 @@
|
||||||
<div id="notifications" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div id="notifications" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
<DynamicScroller :items="notifications" :min-item-size="20" class="scroller" page-mode>
|
<DynamicScroller :items="handledNotifications" :min-item-size="20" class="scroller" page-mode>
|
||||||
<template v-slot="{ item, index, active }">
|
<template v-slot="{ item, index, active }">
|
||||||
<DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.url]" :data-index="index" :watchData="true">
|
<DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.url]" :data-index="index" :watchData="true">
|
||||||
<notification
|
<notification
|
||||||
|
@ -48,12 +48,12 @@ export default {
|
||||||
openSideBar: state => state.TimelineSpace.Contents.SideBar.openSideBar,
|
openSideBar: state => state.TimelineSpace.Contents.SideBar.openSideBar,
|
||||||
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
||||||
backgroundColor: state => state.App.theme.background_color,
|
backgroundColor: state => state.App.theme.background_color,
|
||||||
notifications: state => state.TimelineSpace.Contents.Notifications.notifications,
|
|
||||||
lazyLoading: state => state.TimelineSpace.Contents.Notifications.lazyLoading,
|
lazyLoading: state => state.TimelineSpace.Contents.Notifications.lazyLoading,
|
||||||
heading: state => state.TimelineSpace.Contents.Notifications.heading,
|
heading: state => state.TimelineSpace.Contents.Notifications.heading,
|
||||||
unread: state => state.TimelineSpace.Contents.Notifications.unreadNotifications,
|
unread: state => state.TimelineSpace.Contents.Notifications.unreadNotifications,
|
||||||
filter: state => state.TimelineSpace.Contents.Notifications.filter
|
filter: state => state.TimelineSpace.Contents.Notifications.filter
|
||||||
}),
|
}),
|
||||||
|
...mapGetters('TimelineSpace/Contents/Notifications', ['handledNotifications']),
|
||||||
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
shortcutEnabled: function () {
|
shortcutEnabled: function () {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
|
@ -63,7 +63,7 @@ export default {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Sometimes notifications are deleted, so perhaps focused notification don't exist.
|
// 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
|
return currentIndex === -1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -123,7 +123,10 @@ export default {
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store
|
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(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.notification_fetch_error'),
|
message: this.$t('message.notification_fetch_error'),
|
||||||
|
@ -157,19 +160,19 @@ export default {
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
const currentIndex = this.notifications.findIndex(notification => this.focusedId === notification.id)
|
const currentIndex = this.handledNotifications.findIndex(notification => this.focusedId === notification.id)
|
||||||
if (currentIndex === -1) {
|
if (currentIndex === -1) {
|
||||||
this.focusedId = this.notifications[0].id
|
this.focusedId = this.handledNotifications[0].id
|
||||||
} else if (currentIndex < this.notifications.length) {
|
} else if (currentIndex < this.handledNotifications.length) {
|
||||||
this.focusedId = this.notifications[currentIndex + 1].id
|
this.focusedId = this.handledNotifications[currentIndex + 1].id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusPrev() {
|
focusPrev() {
|
||||||
const currentIndex = this.notifications.findIndex(notification => this.focusedId === notification.id)
|
const currentIndex = this.handledNotifications.findIndex(notification => this.focusedId === notification.id)
|
||||||
if (currentIndex === 0) {
|
if (currentIndex === 0) {
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
} else if (currentIndex > 0) {
|
} else if (currentIndex > 0) {
|
||||||
this.focusedId = this.notifications[currentIndex - 1].id
|
this.focusedId = this.handledNotifications[currentIndex - 1].id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusNotification(notification) {
|
focusNotification(notification) {
|
||||||
|
@ -181,7 +184,7 @@ export default {
|
||||||
handleKey(event) {
|
handleKey(event) {
|
||||||
switch (event.srcKey) {
|
switch (event.srcKey) {
|
||||||
case 'next':
|
case 'next':
|
||||||
this.focusedId = this.notifications[0].id
|
this.focusedId = this.handledNotifications[0].id
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import generator, { Entity } from 'megalodon'
|
import generator, { Entity } from 'megalodon'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
|
||||||
import { RootState } from '@/store'
|
import { RootState } from '@/store'
|
||||||
import { MyWindow } from '~/src/types/global'
|
import { MyWindow } from '~/src/types/global'
|
||||||
|
|
||||||
|
@ -144,11 +144,30 @@ const actions: ActionTree<NotificationsState, RootState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getters: GetterTree<NotificationsState, RootState> = {
|
||||||
|
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<NotificationsState, RootState> = {
|
const Notifications: Module<NotificationsState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
actions: actions
|
actions: actions,
|
||||||
|
getters: getters
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Notifications
|
export default Notifications
|
||||||
|
|
Loading…
Reference in New Issue