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

23 lines
617 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
2020-03-27 13:59:38 -07:00
import { GROUPS_FETCH_SUCCESS } from '../actions/groups';
const initialState = ImmutableMap({
featured: ImmutableList(),
member: ImmutableList(),
admin: ImmutableList(),
});
const normalizeList = (state, type, id, groups) => {
return state.set(type, ImmutableList(groups.map(item => item.id)));
};
export default function groupLists(state = initialState, action) {
switch (action.type) {
2022-05-11 14:06:35 -07:00
case GROUPS_FETCH_SUCCESS:
return normalizeList(state, action.tab, action.id, action.groups);
default:
return state;
2020-03-27 13:59:38 -07:00
}
2021-08-03 12:22:51 -07:00
}