Support Pleroma legacy notification counter, fixes #172

merge-requests/67/merge
Alex Gleason 4 years ago
parent 0e86d03c97
commit 5e60fe1954
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -60,7 +60,7 @@ describe('notifications reducer', () => {
]),
hasMore: false,
top: false,
unread: 0,
unread: 1,
isLoading: false,
queuedNotifications: ImmutableList(),
totalQueuedNotificationsCount: 0,

@ -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:

Loading…
Cancel
Save