Support Pleroma legacy notification counter, fixes #172
This commit is contained in:
parent
0e86d03c97
commit
5e60fe1954
|
@ -60,7 +60,7 @@ describe('notifications reducer', () => {
|
||||||
]),
|
]),
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 0,
|
unread: 1,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableList(),
|
queuedNotifications: ImmutableList(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
|
|
|
@ -140,7 +140,7 @@ export default function notifications(state = initialState, action) {
|
||||||
case SAVE_MARKERS_SUCCESS:
|
case SAVE_MARKERS_SUCCESS:
|
||||||
const prevRead = state.get('lastRead');
|
const prevRead = state.get('lastRead');
|
||||||
const marker = fromJS(action.markers);
|
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);
|
const lastRead = marker.getIn(['notifications', 'last_read_id'], prevRead);
|
||||||
return state.merge({ unread, lastRead });
|
return state.merge({ unread, lastRead });
|
||||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||||
|
@ -161,7 +161,10 @@ export default function notifications(state = initialState, action) {
|
||||||
mutable.set('totalQueuedNotificationsCount', 0);
|
mutable.set('totalQueuedNotificationsCount', 0);
|
||||||
});
|
});
|
||||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
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:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
return filterNotifications(state, action.relationship);
|
return filterNotifications(state, action.relationship);
|
||||||
case ACCOUNT_MUTE_SUCCESS:
|
case ACCOUNT_MUTE_SUCCESS:
|
||||||
|
|
Loading…
Reference in New Issue