2022-01-10 14:01:24 -08:00
|
|
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
import {
|
|
|
|
TRENDS_FETCH_REQUEST,
|
|
|
|
TRENDS_FETCH_SUCCESS,
|
|
|
|
TRENDS_FETCH_FAIL,
|
|
|
|
} from '../actions/trends';
|
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
|
|
|
items: ImmutableList(),
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
export default function trendsReducer(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
2020-04-14 11:44:40 -07:00
|
|
|
case TRENDS_FETCH_REQUEST:
|
|
|
|
return state.set('isLoading', true);
|
|
|
|
case TRENDS_FETCH_SUCCESS:
|
|
|
|
return state.withMutations(map => {
|
|
|
|
map.set('items', fromJS(action.tags.map((x => x))));
|
|
|
|
map.set('isLoading', false);
|
|
|
|
});
|
|
|
|
case TRENDS_FETCH_FAIL:
|
|
|
|
return state.set('isLoading', false);
|
|
|
|
default:
|
|
|
|
return state;
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
2021-08-03 12:22:51 -07:00
|
|
|
}
|