When streaming API is disconnected, poll home/notifications (#2776)
* When streaming API is disconnected, poll home/notifications Display slightly different empty home timeline message if user is following others Cull notifications to 20 items when over 40 get added in real-time Run manage:translations * Optimize <HomeTimeline /> a little
This commit is contained in:
@ -87,7 +87,11 @@ const initialState = Immutable.Map();
|
||||
export default function accountsCounters(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case STORE_HYDRATE:
|
||||
return state.merge(action.state.get('accounts_counters'));
|
||||
return state.merge(action.state.get('accounts').map(item => Immutable.fromJS({
|
||||
followers_count: item.get('followers_count'),
|
||||
following_count: item.get('following_count'),
|
||||
statuses_count: item.get('statuses_count')
|
||||
})));
|
||||
case ACCOUNT_FETCH_SUCCESS:
|
||||
case NOTIFICATIONS_UPDATE:
|
||||
return normalizeAccount(state, action.account);
|
||||
|
@ -29,11 +29,19 @@ const notificationToMap = notification => Immutable.Map({
|
||||
});
|
||||
|
||||
const normalizeNotification = (state, notification) => {
|
||||
if (!state.get('top')) {
|
||||
const top = state.get('top');
|
||||
|
||||
if (!top) {
|
||||
state = state.update('unread', unread => unread + 1);
|
||||
}
|
||||
|
||||
return state.update('items', list => list.unshift(notificationToMap(notification)));
|
||||
return state.update('items', list => {
|
||||
if (top && list.size > 40) {
|
||||
list = list.take(20);
|
||||
}
|
||||
|
||||
return list.unshift(notificationToMap(notification));
|
||||
});
|
||||
};
|
||||
|
||||
const normalizeNotifications = (state, notifications, next) => {
|
||||
|
Reference in New Issue
Block a user