@ -13,6 +13,7 @@ import {
omitBy
omitBy
} from 'lodash'
} from 'lodash'
import { set } from 'vue'
import { set } from 'vue'
import { isStatusNotification } from '../services/notification_utils/notification_utils.js'
import apiService from '../services/api/api.service.js'
import apiService from '../services/api/api.service.js'
// import parse from '../services/status_parser/status_parser.js'
// import parse from '../services/status_parser/status_parser.js'
@ -321,7 +322,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
const addNewNotifications = ( state , { dispatch , notifications , older , visibleNotificationTypes , rootGetters } ) => {
const addNewNotifications = ( state , { dispatch , notifications , older , visibleNotificationTypes , rootGetters } ) => {
each ( notifications , ( notification ) => {
each ( notifications , ( notification ) => {
if ( notification. type !== 'follow' && notification . type !== 'move' ) {
if ( isStatusNotification( notification . type ) ) {
notification . action = addStatusToGlobalStorage ( state , notification . action ) . item
notification . action = addStatusToGlobalStorage ( state , notification . action ) . item
notification . status = notification . status && addStatusToGlobalStorage ( state , notification . status ) . item
notification . status = notification . status && addStatusToGlobalStorage ( state , notification . status ) . item
}
}
@ -361,13 +362,16 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
case 'move' :
case 'move' :
i18nString = 'migrated_to'
i18nString = 'migrated_to'
break
break
case 'follow_request' :
i18nString = 'follow_request'
break
}
}
if ( notification . type === 'pleroma:emoji_reaction' ) {
if ( notification . type === 'pleroma:emoji_reaction' ) {
notifObj . body = rootGetters . i18n . t ( 'notifications.reacted_with' , [ notification . emoji ] )
notifObj . body = rootGetters . i18n . t ( 'notifications.reacted_with' , [ notification . emoji ] )
} else if ( i18nString ) {
} else if ( i18nString ) {
notifObj . body = rootGetters . i18n . t ( 'notifications.' + i18nString )
notifObj . body = rootGetters . i18n . t ( 'notifications.' + i18nString )
} else {
} else if ( isStatusNotification ( notification . type ) ) {
notifObj . body = notification . status . text
notifObj . body = notification . status . text
}
}
@ -521,6 +525,13 @@ export const mutations = {
notification . seen = true
notification . seen = true
} )
} )
} ,
} ,
dismissNotification ( state , { id } ) {
state . notifications . data = state . notifications . data . filter ( n => n . id !== id )
} ,
updateNotification ( state , { id , updater } ) {
const notification = find ( state . notifications . data , n => n . id === id )
notification && updater ( notification )
} ,
queueFlush ( state , { timeline , id } ) {
queueFlush ( state , { timeline , id } ) {
state . timelines [ timeline ] . flushMarker = id
state . timelines [ timeline ] . flushMarker = id
} ,
} ,
@ -680,6 +691,13 @@ const statuses = {
credentials : rootState . users . currentUser . credentials
credentials : rootState . users . currentUser . credentials
} )
} )
} ,
} ,
dismissNotification ( { rootState , commit } , { id } ) {
rootState . api . backendInteractor . dismissNotification ( { id } )
. then ( ( ) => commit ( 'dismissNotification' , { id } ) )
} ,
updateNotification ( { rootState , commit } , { id , updater } ) {
commit ( 'updateNotification' , { id , updater } )
} ,
fetchFavsAndRepeats ( { rootState , commit } , id ) {
fetchFavsAndRepeats ( { rootState , commit } , id ) {
Promise . all ( [
Promise . all ( [
rootState . api . backendInteractor . fetchFavoritedByUsers ( { id } ) ,
rootState . api . backendInteractor . fetchFavoritedByUsers ( { id } ) ,