about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/notifications.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-16 19:39:44 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-09-16 19:39:44 +0200
commitd256901f60b121172ae3a3a7167f9c64d947cf99 (patch)
tree21b6976265df776dad5587eda3f0c60a58d12ecf /app/javascript/mastodon/reducers/notifications.js
parent576377a3822bffecd363583c787f03128c0a8247 (diff)
Change timelines to add new items to pending items when scrolled down (#11867)
Diffstat (limited to 'app/javascript/mastodon/reducers/notifications.js')
-rw-r--r--app/javascript/mastodon/reducers/notifications.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js
index 69bd47940..811550a8a 100644
--- a/app/javascript/mastodon/reducers/notifications.js
+++ b/app/javascript/mastodon/reducers/notifications.js
@@ -35,12 +35,12 @@ const notificationToMap = notification => ImmutableMap({
 });
 
 const normalizeNotification = (state, notification, usePendingItems) => {
-  if (usePendingItems) {
+  const top = state.get('top');
+
+  if (usePendingItems || !top || !state.get('pendingItems').isEmpty()) {
     return state.update('pendingItems', list => list.unshift(notificationToMap(notification))).update('unread', unread => unread + 1);
   }
 
-  const top = state.get('top');
-
   if (!top) {
     state = state.update('unread', unread => unread + 1);
   }
@@ -63,6 +63,8 @@ const expandNormalizedNotifications = (state, notifications, next, usePendingIte
 
   return state.withMutations(mutable => {
     if (!items.isEmpty()) {
+      usePendingItems = usePendingItems || !mutable.get('top') || !mutable.get('pendingItems').isEmpty();
+
       mutable.update(usePendingItems ? 'pendingItems' : 'items', list => {
         const lastIndex = 1 + list.findLastIndex(
           item => item !== null && (compareId(item.get('id'), items.last().get('id')) > 0 || item.get('id') === items.last().get('id'))