|
|
@ -13,7 +13,11 @@ import {
|
|
|
|
omitBy
|
|
|
|
omitBy
|
|
|
|
} from 'lodash'
|
|
|
|
} from 'lodash'
|
|
|
|
import { set } from 'vue'
|
|
|
|
import { set } from 'vue'
|
|
|
|
import { isStatusNotification, maybeShowNotification } from '../services/notification_utils/notification_utils.js'
|
|
|
|
import {
|
|
|
|
|
|
|
|
isStatusNotification,
|
|
|
|
|
|
|
|
isValidNotification,
|
|
|
|
|
|
|
|
maybeShowNotification
|
|
|
|
|
|
|
|
} from '../services/notification_utils/notification_utils.js'
|
|
|
|
import apiService from '../services/api/api.service.js'
|
|
|
|
import apiService from '../services/api/api.service.js'
|
|
|
|
|
|
|
|
|
|
|
|
const emptyTl = (userId = 0) => ({
|
|
|
|
const emptyTl = (userId = 0) => ({
|
|
|
@ -310,8 +314,24 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateNotificationsMinMaxId = (state, notification) => {
|
|
|
|
|
|
|
|
state.notifications.maxId = notification.id > state.notifications.maxId
|
|
|
|
|
|
|
|
? notification.id
|
|
|
|
|
|
|
|
: state.notifications.maxId
|
|
|
|
|
|
|
|
state.notifications.minId = notification.id < state.notifications.minId
|
|
|
|
|
|
|
|
? notification.id
|
|
|
|
|
|
|
|
: state.notifications.minId
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters, newNotificationSideEffects }) => {
|
|
|
|
const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters, newNotificationSideEffects }) => {
|
|
|
|
each(notifications, (notification) => {
|
|
|
|
each(notifications, (notification) => {
|
|
|
|
|
|
|
|
// If invalid notification, update ids but don't add it to store
|
|
|
|
|
|
|
|
if (!isValidNotification(notification)) {
|
|
|
|
|
|
|
|
console.error('Invalid notification:', notification)
|
|
|
|
|
|
|
|
updateNotificationsMinMaxId(state, notification)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isStatusNotification(notification.type)) {
|
|
|
|
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
|
|
|
@ -323,12 +343,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
|
|
|
|
|
|
|
|
|
|
|
|
// Only add a new notification if we don't have one for the same action
|
|
|
|
// Only add a new notification if we don't have one for the same action
|
|
|
|
if (!state.notifications.idStore.hasOwnProperty(notification.id)) {
|
|
|
|
if (!state.notifications.idStore.hasOwnProperty(notification.id)) {
|
|
|
|
state.notifications.maxId = notification.id > state.notifications.maxId
|
|
|
|
updateNotificationsMinMaxId(state, notification)
|
|
|
|
? notification.id
|
|
|
|
|
|
|
|
: state.notifications.maxId
|
|
|
|
|
|
|
|
state.notifications.minId = notification.id < state.notifications.minId
|
|
|
|
|
|
|
|
? notification.id
|
|
|
|
|
|
|
|
: state.notifications.minId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.notifications.data.push(notification)
|
|
|
|
state.notifications.data.push(notification)
|
|
|
|
state.notifications.idStore[notification.id] = notification
|
|
|
|
state.notifications.idStore[notification.id] = notification
|
|
|
|