From 0ab2f179918d6d1c37c80f73cab25e9865a6e796 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sat, 2 Feb 2019 17:04:07 +0300 Subject: [PATCH 1/2] Explicitly cast notification ids to integers when using them for setting maxId This fixes the bug where BE receives incorrect `since_id` when marking notifications as read. --- src/modules/statuses.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 56619455..b58f8404 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -273,10 +273,11 @@ 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 + const notificationId = parseInt(notification.id, 10) + state.notifications.maxId = notificationId > parseInt(state.notifications.maxId, 10) ? notification.id : state.notifications.maxId - state.notifications.minId = notification.id < state.notifications.minId + state.notifications.minId = notificationId < parseInt(state.notifications.minId, 10) ? notification.id : state.notifications.minId From b62d2c76e51c8b00c05cf2c6b071788a5fea9de7 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sat, 2 Feb 2019 18:39:54 +0300 Subject: [PATCH 2/2] Use integer type of notitication ids (avoid redundant casting for getting maxId in addNewNotifications) --- src/modules/statuses.js | 5 ++--- src/services/entity_normalizer/entity_normalizer.service.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index b58f8404..56619455 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -273,11 +273,10 @@ 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)) { - const notificationId = parseInt(notification.id, 10) - state.notifications.maxId = notificationId > parseInt(state.notifications.maxId, 10) + state.notifications.maxId = notification.id > state.notifications.maxId ? notification.id : state.notifications.maxId - state.notifications.minId = notificationId < parseInt(state.notifications.minId, 10) + state.notifications.minId = notification.id < state.notifications.minId ? notification.id : state.notifications.minId diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index fa955ad6..ff4b93ef 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -268,7 +268,7 @@ export const parseNotification = (data) => { } output.created_at = new Date(data.created_at) - output.id = String(data.id) + output.id = data.id return output }