diff --git a/app/soapbox/reducers/__tests__/notifications-test.js b/app/soapbox/reducers/__tests__/notifications-test.js index 50701be19..d805a2cc9 100644 --- a/app/soapbox/reducers/__tests__/notifications-test.js +++ b/app/soapbox/reducers/__tests__/notifications-test.js @@ -60,7 +60,7 @@ describe('notifications reducer', () => { ]), hasMore: false, top: false, - unread: 0, + unread: 1, isLoading: false, queuedNotifications: ImmutableList(), totalQueuedNotificationsCount: 0, diff --git a/app/soapbox/reducers/notifications.js b/app/soapbox/reducers/notifications.js index 6e9fbe7b1..cbf9ef5d5 100644 --- a/app/soapbox/reducers/notifications.js +++ b/app/soapbox/reducers/notifications.js @@ -140,7 +140,7 @@ export default function notifications(state = initialState, action) { case SAVE_MARKERS_SUCCESS: const prevRead = state.get('lastRead'); const marker = fromJS(action.markers); - const unread = marker.getIn(['notifications', 'pleroma', 'unread_count'], 0); + const unread = marker.getIn(['notifications', 'pleroma', 'unread_count'], state.get('unread', 0)); const lastRead = marker.getIn(['notifications', 'last_read_id'], prevRead); return state.merge({ unread, lastRead }); case NOTIFICATIONS_EXPAND_REQUEST: @@ -161,7 +161,10 @@ export default function notifications(state = initialState, action) { mutable.set('totalQueuedNotificationsCount', 0); }); case NOTIFICATIONS_EXPAND_SUCCESS: - return expandNormalizedNotifications(state, action.notifications, action.next); + const legacyUnread = action.notifications.reduce((acc, cur) => + get(cur, ['pleroma', 'is_seen'], false) === false ? acc + 1 : acc, 0); + return expandNormalizedNotifications(state, action.notifications, action.next) + .merge({ unread: Math.max(legacyUnread, state.get('unread')) }); case ACCOUNT_BLOCK_SUCCESS: return filterNotifications(state, action.relationship); case ACCOUNT_MUTE_SUCCESS: