diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-04 23:41:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 23:41:34 +0200 |
commit | eddb95b0126e523faeafbde544ff5df3a64e5b25 (patch) | |
tree | bc24f9595b33c9b621886a7d6ab1a3233ac69b3e /app/javascript/mastodon/reducers/notifications.js | |
parent | 84eb425f385c5fc66dc67973b2869b9f31e9a2bb (diff) |
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
Diffstat (limited to 'app/javascript/mastodon/reducers/notifications.js')
-rw-r--r-- | app/javascript/mastodon/reducers/notifications.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js index c567a3a59..6d53a0ae6 100644 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@ -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) => { |