From 4e8b696797d5c4010abbe12584b8d70badb76a4c Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 25 Feb 2019 12:12:49 -0500 Subject: [PATCH 1/2] #380: fix false alarm for unread notifications --- src/modules/statuses.js | 3 +++ .../notifications_fetcher.service.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 46117fd7..c6fcfe2e 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -303,6 +303,9 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot setTimeout(notification.close.bind(notification), 5000) } } + } else if (notification.seen) { + state.notifications.data.find(n => n.id === notification.id).seen = true + state.notifications.idStore[notification.id].seen = true } }) } diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index b69ec643..3ecdae6a 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -16,7 +16,17 @@ const fetchAndUpdate = ({store, credentials, older = false}) => { args['until'] = timelineData.minId } } else { - args['since'] = timelineData.maxId + // load unread notifications repeadedly to provide consistency between browser tabs + const notifications = timelineData.data + const unread = notifications.filter(n => !n.seen).map(n => n.id) + if (!unread.length) { + args['since'] = timelineData.maxId + } else { + args['since'] = Math.min(...unread) - 1 + if (timelineData.maxId !== Math.max(...unread)) { + args['until'] = Math.max(...unread, args['since'] + 20) + } + } } args['timeline'] = 'notifications' From 7dbbd8e27028e7526154542d210c4f6452d5e433 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 25 Feb 2019 14:57:56 -0500 Subject: [PATCH 2/2] #380: simply and remove redundancy --- src/modules/statuses.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index c6fcfe2e..694067ff 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -304,7 +304,6 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot } } } else if (notification.seen) { - state.notifications.data.find(n => n.id === notification.id).seen = true state.notifications.idStore[notification.id].seen = true } })