about summary refs log tree commit diff
path: root/app/javascript/flavours
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-08-25 19:30:24 +0200
committerGitHub <noreply@github.com>2022-08-25 19:30:24 +0200
commit978dd7e73c911441503ff803ffdce544ce50a33d (patch)
tree297a8dab67c99abbdf051d3273e1b3a9c8d0b75c /app/javascript/flavours
parentacc580fb7d40641e0bb5ba7a3145503bcb8397c3 (diff)
parentd99f91bceb01b8d7bd48a3872d894226512cc09f (diff)
Merge pull request #1830 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r--app/javascript/flavours/glitch/actions/notifications.js17
-rw-r--r--app/javascript/flavours/glitch/reducers/filters.js2
2 files changed, 13 insertions, 6 deletions
diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js
index ae3ee1a4c..4581ebc36 100644
--- a/app/javascript/flavours/glitch/actions/notifications.js
+++ b/app/javascript/flavours/glitch/actions/notifications.js
@@ -153,15 +153,22 @@ const excludeTypesFromFilter = filter => {
 
 const noOp = () => {};
 
+let expandNotificationsController = new AbortController();
+
 export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) {
   return (dispatch, getState) => {
     const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
     const notifications = getState().get('notifications');
     const isLoadingMore = !!maxId;
 
-    if (notifications.get('isLoading') && !forceLoad) {
-      done();
-      return;
+    if (notifications.get('isLoading')) {
+      if (forceLoad) {
+        expandNotificationsController.abort();
+        expandNotificationsController = new AbortController();
+      } else {
+        done();
+        return;
+      }
     }
 
     const params = {
@@ -186,7 +193,7 @@ export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) {
 
     dispatch(expandNotificationsRequest(isLoadingMore));
 
-    api(getState).get('/api/v1/notifications', { params }).then(response => {
+    api(getState).get('/api/v1/notifications', { params, signal: expandNotificationsController.signal }).then(response => {
       const next = getLinks(response).refs.find(link => link.rel === 'next');
 
       dispatch(importFetchedAccounts(response.data.map(item => item.account)));
@@ -227,7 +234,7 @@ export function expandNotificationsFail(error, isLoadingMore) {
     type: NOTIFICATIONS_EXPAND_FAIL,
     error,
     skipLoading: !isLoadingMore,
-    skipAlert: !isLoadingMore,
+    skipAlert: !isLoadingMore || error.name === 'AbortError',
   };
 };
 
diff --git a/app/javascript/flavours/glitch/reducers/filters.js b/app/javascript/flavours/glitch/reducers/filters.js
index cc1d3349c..f4f97cd3a 100644
--- a/app/javascript/flavours/glitch/reducers/filters.js
+++ b/app/javascript/flavours/glitch/reducers/filters.js
@@ -35,7 +35,7 @@ export default function filters(state = ImmutableMap(), action) {
   case FILTERS_CREATE_SUCCESS:
     return normalizeFilter(state, action.filter);
   case FILTERS_FETCH_SUCCESS:
-    //TODO: handle deleting obsolete filters
+    return normalizeFilters(ImmutableMap(), action.filters);
   case FILTERS_IMPORT:
     return normalizeFilters(state, action.filters);
   default: