aboutsummaryrefslogtreecommitdiff
path: root/src/modules/statuses.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-01-11 03:00:11 +0300
committerHenry Jameson <me@hjkos.com>2019-01-11 03:00:11 +0300
commit48e811e6edc774affa3526e7a25df6bb07597c9d (patch)
treea461f78dab0c97b590aebe558d130d174726205b /src/modules/statuses.js
parentef2585e32b546722f2157bd6203701deb495d2e9 (diff)
added some more explicit to string conversion since BE seem to be sending
numbers and it could cause an issue.
Diffstat (limited to 'src/modules/statuses.js')
-rw-r--r--src/modules/statuses.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index fe65d843..05626a02 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -105,6 +105,9 @@ export const findMaxId = (...args) => {
}
const mergeOrAdd = (arr, obj, item) => {
+ // For sequential IDs BE passes numbers as numbers, we want them as strings.
+ item.id = String(item.id)
+
const oldItem = obj[item.id]
if (oldItem) {
@@ -292,8 +295,13 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
each(notifications, (notification) => {
const result = mergeOrAdd(allStatuses, allStatusesObject, notification.notice)
const action = result.item
+ // For sequential IDs BE passes numbers as numbers, we want them as strings.
+ action.id = String(action.id)
+
// Only add a new notification if we don't have one for the same action
+ // TODO: this technically works but should be checking for notification.id, not action.id i think
if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) {
+ // TODO: adapt to "what if notification ids are not actually numbers"
state.notifications.maxId = Math.max(notification.id, state.notifications.maxId)
state.notifications.minId = Math.min(notification.id, state.notifications.minId)