about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/trends.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-06-01 21:22:42 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-06-01 14:22:42 +0200
commit69b45350fe680ef5491eb8cacba92770b04ca1dd (patch)
tree4e6a1cd04f36ebd49baa379adff321825b64a5ee /app/javascript/mastodon/reducers/trends.js
parentbfa12239e84ebe310d74ef0e773d90a477b3cf8f (diff)
Add loading indicator for trending tags (#7693)
Diffstat (limited to 'app/javascript/mastodon/reducers/trends.js')
-rw-r--r--app/javascript/mastodon/reducers/trends.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/javascript/mastodon/reducers/trends.js b/app/javascript/mastodon/reducers/trends.js
index 95cf8f284..5cecc8fca 100644
--- a/app/javascript/mastodon/reducers/trends.js
+++ b/app/javascript/mastodon/reducers/trends.js
@@ -1,12 +1,22 @@
-import { TRENDS_FETCH_SUCCESS } from '../actions/trends';
-import { fromJS } from 'immutable';
+import { TRENDS_FETCH_REQUEST, TRENDS_FETCH_SUCCESS, TRENDS_FETCH_FAIL } from '../actions/trends';
+import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
 
-const initialState = null;
+const initialState = ImmutableMap({
+  items: ImmutableList(),
+  isLoading: false,
+});
 
 export default function trendsReducer(state = initialState, action) {
   switch(action.type) {
+  case TRENDS_FETCH_REQUEST:
+    return state.set('isLoading', true);
   case TRENDS_FETCH_SUCCESS:
-    return fromJS(action.trends);
+    return state.withMutations(map => {
+      map.set('items', fromJS(action.trends));
+      map.set('isLoading', false);
+    });
+  case TRENDS_FETCH_FAIL:
+    return state.set('isLoading', false);
   default:
     return state;
   }