Refactoring redux state into different reducers
This commit is contained in:
parent
7060bdf04b
commit
e8ff4c8e56
23 changed files with 352 additions and 223 deletions
|
@ -1,12 +1,14 @@
|
|||
import {
|
||||
FOLLOWERS_FETCH_SUCCESS,
|
||||
FOLLOWING_FETCH_SUCCESS
|
||||
} from '../actions/accounts';
|
||||
import Immutable from 'immutable';
|
||||
} from '../actions/accounts';
|
||||
import { SUGGESTIONS_FETCH_SUCCESS } from '../actions/suggestions';
|
||||
import Immutable from 'immutable';
|
||||
|
||||
const initialState = Immutable.Map({
|
||||
followers: Immutable.Map(),
|
||||
following: Immutable.Map()
|
||||
following: Immutable.Map(),
|
||||
suggestions: Immutable.List()
|
||||
});
|
||||
|
||||
export default function userLists(state = initialState, action) {
|
||||
|
@ -15,6 +17,8 @@ export default function userLists(state = initialState, action) {
|
|||
return state.setIn(['followers', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
||||
case FOLLOWING_FETCH_SUCCESS:
|
||||
return state.setIn(['following', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
||||
case SUGGESTIONS_FETCH_SUCCESS:
|
||||
return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id)));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue