0
0
Fork 0

Add loading indicator for trending tags (#7693)

This commit is contained in:
Yamagishi Kazutoshi 2018-06-01 21:22:42 +09:00 committed by Eugen Rochko
parent bfa12239e8
commit 69b45350fe
6 changed files with 104 additions and 41 deletions

View file

@ -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;
}