about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/notifications.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-08-25 04:29:00 +0200
committerGitHub <noreply@github.com>2022-08-25 04:29:00 +0200
commitafb8bc97d08c2738da7873ca42fea68e4672d65b (patch)
tree93f66d05bcb1105f34f1a1191e9759c5473b27ca /app/javascript/mastodon/reducers/notifications.js
parent50487db1224851a49ee523bbc013d5f8686a7a55 (diff)
Fix quickly switching notification filters resulting in empty or incorrect list (#18960)
Diffstat (limited to 'app/javascript/mastodon/reducers/notifications.js')
-rw-r--r--app/javascript/mastodon/reducers/notifications.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js
index 4563118ea..eb34edb63 100644
--- a/app/javascript/mastodon/reducers/notifications.js
+++ b/app/javascript/mastodon/reducers/notifications.js
@@ -41,7 +41,7 @@ const initialState = ImmutableMap({
   lastReadId: '0',
   readMarkerId: '0',
   isTabVisible: true,
-  isLoading: false,
+  isLoading: 0,
   browserSupport: false,
   browserPermission: 'default',
 });
@@ -115,7 +115,7 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingRece
       }
     }
 
-    mutable.set('isLoading', false);
+    mutable.update('isLoading', (nbLoading) => nbLoading - 1);
   });
 };
 
@@ -214,9 +214,9 @@ export default function notifications(state = initialState, action) {
   case NOTIFICATIONS_LOAD_PENDING:
     return state.update('items', list => state.get('pendingItems').concat(list.take(40))).set('pendingItems', ImmutableList()).set('unread', 0);
   case NOTIFICATIONS_EXPAND_REQUEST:
-    return state.set('isLoading', true);
+    return state.update('isLoading', (nbLoading) => nbLoading + 1);
   case NOTIFICATIONS_EXPAND_FAIL:
-    return state.set('isLoading', false);
+    return state.update('isLoading', (nbLoading) => nbLoading - 1);
   case NOTIFICATIONS_FILTER_SET:
     return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', true);
   case NOTIFICATIONS_SCROLL_TOP: