bigbuffet-rw/app/soapbox/reducers/trends.js

29 lines
736 B
JavaScript
Raw Normal View History

import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
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(),
2020-03-27 13:59:38 -07:00
isLoading: false,
});
export default function trendsReducer(state = initialState, action) {
switch (action.type) {
2022-05-11 14:06:35 -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))));
2022-05-11 14:06:35 -07:00
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
}