diff options
| author | Shpuld Shpludson <shp@cock.li> | 2021-02-28 15:37:39 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2021-02-28 15:37:39 +0000 |
| commit | 91f93d4a55cbf927a6adee35dc184b09d1f9b75d (patch) | |
| tree | 882fb179fa7ed36e6c212a4874559b27a73f3d1e /src/modules/statuses.js | |
| parent | 670abd633f97e75cf35981ee0f617d0be1b43816 (diff) | |
| parent | b4782ad159026e3fb50c476e5cf9d89176e441f4 (diff) | |
Merge branch 'develop' into 'feat/timeline-quick-settings'
# Conflicts:
# CHANGELOG.md
Diffstat (limited to 'src/modules/statuses.js')
| -rw-r--r-- | src/modules/statuses.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 33c68c57..ac5d25c4 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -13,7 +13,11 @@ import { omitBy } from 'lodash' 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' 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 }) => { 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)) { notification.action = addStatusToGlobalStorage(state, notification.action).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 if (!state.notifications.idStore.hasOwnProperty(notification.id)) { - 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 + updateNotificationsMinMaxId(state, notification) state.notifications.data.push(notification) state.notifications.idStore[notification.id] = notification |
