Refactor notifications again, this time with OrderedMap, fixes #433
This commit is contained in:
parent
9c0793d1f3
commit
f183094f82
4 changed files with 119 additions and 122 deletions
|
@ -13,7 +13,7 @@ import { defineMessages } from 'react-intl';
|
||||||
import {
|
import {
|
||||||
List as ImmutableList,
|
List as ImmutableList,
|
||||||
Map as ImmutableMap,
|
Map as ImmutableMap,
|
||||||
OrderedSet as ImmutableOrderedSet,
|
OrderedMap as ImmutableOrderedMap,
|
||||||
} from 'immutable';
|
} from 'immutable';
|
||||||
import { unescapeHTML } from '../utils/html';
|
import { unescapeHTML } from '../utils/html';
|
||||||
import { getFilters, regexFromFilters } from '../selectors';
|
import { getFilters, regexFromFilters } from '../selectors';
|
||||||
|
@ -125,7 +125,7 @@ export function updateNotificationsQueue(notification, intlMessages, intlLocale,
|
||||||
|
|
||||||
export function dequeueNotifications() {
|
export function dequeueNotifications() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const queuedNotifications = getState().getIn(['notifications', 'queuedNotifications'], ImmutableOrderedSet());
|
const queuedNotifications = getState().getIn(['notifications', 'queuedNotifications'], ImmutableOrderedMap());
|
||||||
const totalQueuedNotificationsCount = getState().getIn(['notifications', 'totalQueuedNotificationsCount'], 0);
|
const totalQueuedNotificationsCount = getState().getIn(['notifications', 'totalQueuedNotificationsCount'], 0);
|
||||||
|
|
||||||
if (totalQueuedNotificationsCount === 0) {
|
if (totalQueuedNotificationsCount === 0) {
|
||||||
|
@ -259,7 +259,7 @@ export function markReadNotifications() {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
if (!state.get('me')) return;
|
if (!state.get('me')) return;
|
||||||
|
|
||||||
const topNotification = state.getIn(['notifications', 'items'], ImmutableOrderedSet()).first(ImmutableMap()).get('id');
|
const topNotification = state.getIn(['notifications', 'items'], ImmutableOrderedMap()).first(ImmutableMap()).get('id');
|
||||||
const lastRead = state.getIn(['notifications', 'lastRead']);
|
const lastRead = state.getIn(['notifications', 'lastRead']);
|
||||||
|
|
||||||
if (!(topNotification && topNotification > lastRead)) return;
|
if (!(topNotification && topNotification > lastRead)) return;
|
||||||
|
|
|
@ -30,7 +30,7 @@ const getNotifications = createSelector([
|
||||||
state => getSettings(state).getIn(['notifications', 'quickFilter', 'show']),
|
state => getSettings(state).getIn(['notifications', 'quickFilter', 'show']),
|
||||||
state => getSettings(state).getIn(['notifications', 'quickFilter', 'active']),
|
state => getSettings(state).getIn(['notifications', 'quickFilter', 'active']),
|
||||||
state => ImmutableList(getSettings(state).getIn(['notifications', 'shows']).filter(item => !item).keys()),
|
state => ImmutableList(getSettings(state).getIn(['notifications', 'shows']).filter(item => !item).keys()),
|
||||||
state => state.getIn(['notifications', 'items']),
|
state => state.getIn(['notifications', 'items']).toList(),
|
||||||
], (showFilterBar, allowedType, excludedTypes, notifications) => {
|
], (showFilterBar, allowedType, excludedTypes, notifications) => {
|
||||||
if (!showFilterBar || allowedType === 'all') {
|
if (!showFilterBar || allowedType === 'all') {
|
||||||
// used if user changed the notification settings after loading the notifications from the server
|
// used if user changed the notification settings after loading the notifications from the server
|
||||||
|
@ -55,7 +55,7 @@ export default @connect(mapStateToProps)
|
||||||
class Notifications extends React.PureComponent {
|
class Notifications extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
notifications: ImmutablePropTypes.orderedSet.isRequired,
|
notifications: ImmutablePropTypes.list.isRequired,
|
||||||
showFilterBar: PropTypes.bool.isRequired,
|
showFilterBar: PropTypes.bool.isRequired,
|
||||||
dispatch: PropTypes.func.isRequired,
|
dispatch: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
@ -142,8 +142,6 @@ class Notifications extends React.PureComponent {
|
||||||
} else if (notifications.size > 0 || hasMore) {
|
} else if (notifications.size > 0 || hasMore) {
|
||||||
scrollableContent = notifications.map((item, index) => item === null ? (
|
scrollableContent = notifications.map((item, index) => item === null ? (
|
||||||
<LoadGap
|
<LoadGap
|
||||||
// FIXME: This won't work, can't get OrderedSet by index
|
|
||||||
// https://github.com/immutable-js/immutable-js/issues/1790
|
|
||||||
key={'gap:' + notifications.getIn([index + 1, 'id'])}
|
key={'gap:' + notifications.getIn([index + 1, 'id'])}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
|
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as actions from 'soapbox/actions/notifications';
|
import * as actions from 'soapbox/actions/notifications';
|
||||||
import reducer from '../notifications';
|
import reducer from '../notifications';
|
||||||
import notifications from 'soapbox/__fixtures__/notifications.json';
|
import notifications from 'soapbox/__fixtures__/notifications.json';
|
||||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
import { Map as ImmutableMap, OrderedMap as ImmutableOrderedMap } from 'immutable';
|
||||||
import { take } from 'lodash';
|
import { take } from 'lodash';
|
||||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
|
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
|
||||||
import notification from 'soapbox/__fixtures__/notification.json';
|
import notification from 'soapbox/__fixtures__/notification.json';
|
||||||
|
@ -12,12 +12,12 @@ import { TIMELINE_DELETE } from 'soapbox/actions/timelines';
|
||||||
describe('notifications reducer', () => {
|
describe('notifications reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet(),
|
items: ImmutableOrderedMap(),
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 0,
|
unread: 0,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableOrderedSet(),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
lastRead: -1,
|
lastRead: -1,
|
||||||
}));
|
}));
|
||||||
|
@ -32,8 +32,8 @@ describe('notifications reducer', () => {
|
||||||
skipLoading: true,
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -42,8 +42,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -52,8 +52,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -62,13 +62,13 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 1,
|
unread: 1,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableOrderedSet(),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
lastRead: -1,
|
lastRead: -1,
|
||||||
}));
|
}));
|
||||||
|
@ -100,8 +100,8 @@ describe('notifications reducer', () => {
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_FILTER_SET', () => {
|
it('should handle NOTIFICATIONS_FILTER_SET', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -110,8 +110,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -120,8 +120,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -130,13 +130,13 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 1,
|
unread: 1,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableOrderedSet(),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
lastRead: -1,
|
lastRead: -1,
|
||||||
});
|
});
|
||||||
|
@ -144,12 +144,12 @@ describe('notifications reducer', () => {
|
||||||
type: actions.NOTIFICATIONS_FILTER_SET,
|
type: actions.NOTIFICATIONS_FILTER_SET,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet(),
|
items: ImmutableOrderedMap(),
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 1,
|
unread: 1,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableOrderedSet(),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
lastRead: -1,
|
lastRead: -1,
|
||||||
}));
|
}));
|
||||||
|
@ -185,7 +185,7 @@ describe('notifications reducer', () => {
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_UPDATE, when top = false, increment unread', () => {
|
it('should handle NOTIFICATIONS_UPDATE, when top = false, increment unread', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet(),
|
items: ImmutableOrderedMap(),
|
||||||
top: false,
|
top: false,
|
||||||
unread: 1,
|
unread: 1,
|
||||||
});
|
});
|
||||||
|
@ -194,8 +194,8 @@ describe('notifications reducer', () => {
|
||||||
notification: notification,
|
notification: notification,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -204,7 +204,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
top: false,
|
top: false,
|
||||||
unread: 2,
|
unread: 2,
|
||||||
|
@ -213,8 +213,8 @@ describe('notifications reducer', () => {
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_UPDATE_QUEUE', () => {
|
it('should handle NOTIFICATIONS_UPDATE_QUEUE', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
queuedNotifications: ImmutableOrderedSet([]),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
|
@ -224,19 +224,19 @@ describe('notifications reducer', () => {
|
||||||
intlLocale: 'en',
|
intlLocale: 'en',
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
queuedNotifications: ImmutableOrderedSet([{
|
queuedNotifications: ImmutableOrderedMap([[notification.id, {
|
||||||
notification: notification,
|
notification: notification,
|
||||||
intlMessages: intlMessages,
|
intlMessages: intlMessages,
|
||||||
intlLocale: 'en',
|
intlLocale: 'en',
|
||||||
}]),
|
}]]),
|
||||||
totalQueuedNotificationsCount: 1,
|
totalQueuedNotificationsCount: 1,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_DEQUEUE', () => {
|
it('should handle NOTIFICATIONS_DEQUEUE', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
queuedNotifications: take(notifications, 1),
|
queuedNotifications: take(notifications, 1),
|
||||||
totalQueuedNotificationsCount: 1,
|
totalQueuedNotificationsCount: 1,
|
||||||
});
|
});
|
||||||
|
@ -244,16 +244,16 @@ describe('notifications reducer', () => {
|
||||||
type: actions.NOTIFICATIONS_DEQUEUE,
|
type: actions.NOTIFICATIONS_DEQUEUE,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
queuedNotifications: ImmutableOrderedSet([]),
|
queuedNotifications: ImmutableOrderedMap(),
|
||||||
totalQueuedNotificationsCount: 0,
|
totalQueuedNotificationsCount: 0,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_EXPAND_SUCCESS with non-empty items and next set true', () => {
|
it('should handle NOTIFICATIONS_EXPAND_SUCCESS with non-empty items and next set true', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10734', ImmutableMap({
|
||||||
id: '10734',
|
id: '10734',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -262,7 +262,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
unread: 1,
|
unread: 1,
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
|
@ -274,8 +274,8 @@ describe('notifications reducer', () => {
|
||||||
next: true,
|
next: true,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -284,8 +284,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -294,8 +294,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -304,8 +304,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10734', ImmutableMap({
|
||||||
id: '10734',
|
id: '10734',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -314,7 +314,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
unread: 1,
|
unread: 1,
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
|
@ -324,7 +324,7 @@ describe('notifications reducer', () => {
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_EXPAND_SUCCESS with empty items and next set true', () => {
|
it('should handle NOTIFICATIONS_EXPAND_SUCCESS with empty items and next set true', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
unread: 1,
|
unread: 1,
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
@ -335,8 +335,8 @@ describe('notifications reducer', () => {
|
||||||
next: true,
|
next: true,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -345,8 +345,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -355,8 +355,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -365,7 +365,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
unread: 1,
|
unread: 1,
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
|
@ -375,8 +375,8 @@ describe('notifications reducer', () => {
|
||||||
|
|
||||||
it('should handle ACCOUNT_BLOCK_SUCCESS', () => {
|
it('should handle ACCOUNT_BLOCK_SUCCESS', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -385,8 +385,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -395,8 +395,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -405,7 +405,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
|
@ -413,8 +413,8 @@ describe('notifications reducer', () => {
|
||||||
relationship: relationship,
|
relationship: relationship,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -423,8 +423,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -433,15 +433,15 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle ACCOUNT_MUTE_SUCCESS', () => {
|
it('should handle ACCOUNT_MUTE_SUCCESS', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -450,8 +450,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -460,8 +460,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -470,7 +470,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
|
@ -478,8 +478,8 @@ describe('notifications reducer', () => {
|
||||||
relationship: relationship,
|
relationship: relationship,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -488,8 +488,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -498,43 +498,43 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_CLEAR', () => {
|
it('should handle NOTIFICATIONS_CLEAR', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.NOTIFICATIONS_CLEAR,
|
type: actions.NOTIFICATIONS_CLEAR,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_MARK_READ_REQUEST', () => {
|
it('should handle NOTIFICATIONS_MARK_READ_REQUEST', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.NOTIFICATIONS_MARK_READ_REQUEST,
|
type: actions.NOTIFICATIONS_MARK_READ_REQUEST,
|
||||||
lastRead: 35098814,
|
lastRead: 35098814,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
lastRead: 35098814,
|
lastRead: 35098814,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle TIMELINE_DELETE', () => {
|
it('should handle TIMELINE_DELETE', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
items: ImmutableOrderedSet([
|
items: ImmutableOrderedMap([
|
||||||
ImmutableMap({
|
['10744', ImmutableMap({
|
||||||
id: '10744',
|
id: '10744',
|
||||||
type: 'pleroma:emoji_reaction',
|
type: 'pleroma:emoji_reaction',
|
||||||
account: '9vMAje101ngtjlMj7w',
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
@ -543,8 +543,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: '😢',
|
emoji: '😢',
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: false,
|
is_seen: false,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10743', ImmutableMap({
|
||||||
id: '10743',
|
id: '10743',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5c6xSEgAi3Zu1Lv6',
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
@ -553,8 +553,8 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
ImmutableMap({
|
['10741', ImmutableMap({
|
||||||
id: '10741',
|
id: '10741',
|
||||||
type: 'favourite',
|
type: 'favourite',
|
||||||
account: '9v5cKMOPGqPcgfcWp6',
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
@ -563,7 +563,7 @@ describe('notifications reducer', () => {
|
||||||
emoji: undefined,
|
emoji: undefined,
|
||||||
chat_message: undefined,
|
chat_message: undefined,
|
||||||
is_seen: true,
|
is_seen: true,
|
||||||
}),
|
})],
|
||||||
]),
|
]),
|
||||||
});
|
});
|
||||||
const action = {
|
const action = {
|
||||||
|
@ -571,7 +571,7 @@ describe('notifications reducer', () => {
|
||||||
id: '9vvNxoo5EFbbnfdXQu',
|
id: '9vvNxoo5EFbbnfdXQu',
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
items: ImmutableOrderedSet([]),
|
items: ImmutableOrderedMap(),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,16 @@ import {
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
import { Map as ImmutableMap, OrderedMap as ImmutableOrderedMap } from 'immutable';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
items: ImmutableOrderedSet(),
|
items: ImmutableOrderedMap(),
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
top: false,
|
top: false,
|
||||||
unread: 0,
|
unread: 0,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
queuedNotifications: ImmutableOrderedSet(), //max = MAX_QUEUED_NOTIFICATIONS
|
queuedNotifications: ImmutableOrderedMap(), //max = MAX_QUEUED_NOTIFICATIONS
|
||||||
totalQueuedNotificationsCount: 0, //used for queuedItems overflow for MAX_QUEUED_NOTIFICATIONS+
|
totalQueuedNotificationsCount: 0, //used for queuedItems overflow for MAX_QUEUED_NOTIFICATIONS+
|
||||||
lastRead: -1,
|
lastRead: -1,
|
||||||
});
|
});
|
||||||
|
@ -56,26 +56,27 @@ const normalizeNotification = (state, notification) => {
|
||||||
|
|
||||||
if (!top) state = state.update('unread', unread => unread + 1);
|
if (!top) state = state.update('unread', unread => unread + 1);
|
||||||
|
|
||||||
return state.update('items', list => {
|
return state.update('items', map => {
|
||||||
if (top && list.size > 40) {
|
if (top && map.size > 40) {
|
||||||
list = list.take(20);
|
map = map.take(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.add(notificationToMap(notification)).sort(comparator);
|
return map.set(notification.id, notificationToMap(notification)).sort(comparator);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const processRawNotifications = notifications => (
|
const processRawNotifications = notifications => (
|
||||||
ImmutableOrderedSet(
|
ImmutableOrderedMap(
|
||||||
notifications
|
notifications
|
||||||
.filter(isValid)
|
.filter(isValid)
|
||||||
.map(notificationToMap)));
|
.map(n => [n.id, notificationToMap(n)])
|
||||||
|
));
|
||||||
|
|
||||||
const expandNormalizedNotifications = (state, notifications, next) => {
|
const expandNormalizedNotifications = (state, notifications, next) => {
|
||||||
const items = processRawNotifications(notifications);
|
const items = processRawNotifications(notifications);
|
||||||
|
|
||||||
return state.withMutations(mutable => {
|
return state.withMutations(mutable => {
|
||||||
mutable.update('items', list => list.union(items).sort(comparator));
|
mutable.update('items', map => map.merge(items).sort(comparator));
|
||||||
|
|
||||||
if (!next) mutable.set('hasMore', false);
|
if (!next) mutable.set('hasMore', false);
|
||||||
mutable.set('isLoading', false);
|
mutable.set('isLoading', false);
|
||||||
|
@ -83,7 +84,7 @@ const expandNormalizedNotifications = (state, notifications, next) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterNotifications = (state, relationship) => {
|
const filterNotifications = (state, relationship) => {
|
||||||
return state.update('items', list => list.filterNot(item => item !== null && item.get('account') === relationship.id));
|
return state.update('items', map => map.filterNot(item => item !== null && item.get('account') === relationship.id));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTop = (state, top) => {
|
const updateTop = (state, top) => {
|
||||||
|
@ -92,26 +93,22 @@ const updateTop = (state, top) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteByStatus = (state, statusId) => {
|
const deleteByStatus = (state, statusId) => {
|
||||||
return state.update('items', list => list.filterNot(item => item !== null && item.get('status') === statusId));
|
return state.update('items', map => map.filterNot(item => item !== null && item.get('status') === statusId));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateNotificationsQueue = (state, notification, intlMessages, intlLocale) => {
|
const updateNotificationsQueue = (state, notification, intlMessages, intlLocale) => {
|
||||||
const queuedNotifications = state.getIn(['queuedNotifications'], ImmutableOrderedSet());
|
const queuedNotifications = state.getIn(['queuedNotifications'], ImmutableOrderedMap());
|
||||||
const listedNotifications = state.getIn(['items'], ImmutableOrderedSet());
|
const listedNotifications = state.getIn(['items'], ImmutableOrderedMap());
|
||||||
const totalQueuedNotificationsCount = state.getIn(['totalQueuedNotificationsCount'], 0);
|
const totalQueuedNotificationsCount = state.getIn(['totalQueuedNotificationsCount'], 0);
|
||||||
|
|
||||||
let alreadyExists = queuedNotifications.find(existingQueuedNotification => existingQueuedNotification.id === notification.id);
|
const alreadyExists = queuedNotifications.has(notification.id) || listedNotifications.has(notification.id);
|
||||||
if (!alreadyExists) alreadyExists = listedNotifications.find(existingListedNotification => existingListedNotification.get('id') === notification.id);
|
if (alreadyExists) return state;
|
||||||
|
|
||||||
if (alreadyExists) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
let newQueuedNotifications = queuedNotifications;
|
let newQueuedNotifications = queuedNotifications;
|
||||||
|
|
||||||
return state.withMutations(mutable => {
|
return state.withMutations(mutable => {
|
||||||
if (totalQueuedNotificationsCount <= MAX_QUEUED_NOTIFICATIONS) {
|
if (totalQueuedNotificationsCount <= MAX_QUEUED_NOTIFICATIONS) {
|
||||||
mutable.set('queuedNotifications', newQueuedNotifications.add({
|
mutable.set('queuedNotifications', newQueuedNotifications.set(notification.id, {
|
||||||
notification,
|
notification,
|
||||||
intlMessages,
|
intlMessages,
|
||||||
intlLocale,
|
intlLocale,
|
||||||
|
@ -121,6 +118,9 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const countUnseen = notifications => notifications.reduce((acc, cur) =>
|
||||||
|
get(cur, ['pleroma', 'is_seen'], false) === false ? acc + 1 : acc, 0);
|
||||||
|
|
||||||
export default function notifications(state = initialState, action) {
|
export default function notifications(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||||
|
@ -128,7 +128,7 @@ export default function notifications(state = initialState, action) {
|
||||||
case NOTIFICATIONS_EXPAND_FAIL:
|
case NOTIFICATIONS_EXPAND_FAIL:
|
||||||
return state.set('isLoading', false);
|
return state.set('isLoading', false);
|
||||||
case NOTIFICATIONS_FILTER_SET:
|
case NOTIFICATIONS_FILTER_SET:
|
||||||
return state.set('items', ImmutableOrderedSet()).set('hasMore', true);
|
return state.set('items', ImmutableOrderedMap()).set('hasMore', true);
|
||||||
case NOTIFICATIONS_SCROLL_TOP:
|
case NOTIFICATIONS_SCROLL_TOP:
|
||||||
return updateTop(state, action.top);
|
return updateTop(state, action.top);
|
||||||
case NOTIFICATIONS_UPDATE:
|
case NOTIFICATIONS_UPDATE:
|
||||||
|
@ -137,12 +137,11 @@ export default function notifications(state = initialState, action) {
|
||||||
return updateNotificationsQueue(state, action.notification, action.intlMessages, action.intlLocale);
|
return updateNotificationsQueue(state, action.notification, action.intlMessages, action.intlLocale);
|
||||||
case NOTIFICATIONS_DEQUEUE:
|
case NOTIFICATIONS_DEQUEUE:
|
||||||
return state.withMutations(mutable => {
|
return state.withMutations(mutable => {
|
||||||
mutable.set('queuedNotifications', ImmutableOrderedSet());
|
mutable.set('queuedNotifications', ImmutableOrderedMap());
|
||||||
mutable.set('totalQueuedNotificationsCount', 0);
|
mutable.set('totalQueuedNotificationsCount', 0);
|
||||||
});
|
});
|
||||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||||
const legacyUnread = action.notifications.reduce((acc, cur) =>
|
const legacyUnread = countUnseen(action.notifications);
|
||||||
get(cur, ['pleroma', 'is_seen'], false) === false ? acc + 1 : acc, 0);
|
|
||||||
return expandNormalizedNotifications(state, action.notifications, action.next)
|
return expandNormalizedNotifications(state, action.notifications, action.next)
|
||||||
.merge({ unread: Math.max(legacyUnread, state.get('unread')) });
|
.merge({ unread: Math.max(legacyUnread, state.get('unread')) });
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
|
@ -150,7 +149,7 @@ export default function notifications(state = initialState, action) {
|
||||||
case ACCOUNT_MUTE_SUCCESS:
|
case ACCOUNT_MUTE_SUCCESS:
|
||||||
return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state;
|
return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state;
|
||||||
case NOTIFICATIONS_CLEAR:
|
case NOTIFICATIONS_CLEAR:
|
||||||
return state.set('items', ImmutableOrderedSet()).set('hasMore', false);
|
return state.set('items', ImmutableOrderedMap()).set('hasMore', false);
|
||||||
case NOTIFICATIONS_MARK_READ_REQUEST:
|
case NOTIFICATIONS_MARK_READ_REQUEST:
|
||||||
return state.set('lastRead', action.lastRead);
|
return state.set('lastRead', action.lastRead);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
|
|
Loading…
Reference in a new issue