You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.0 KiB

  1. import {
  2. FOLLOWERS_FETCH_SUCCESS,
  3. FOLLOWING_FETCH_SUCCESS
  4. } from '../actions/accounts';
  5. import { SUGGESTIONS_FETCH_SUCCESS } from '../actions/suggestions';
  6. import { REBLOGS_FETCH_SUCCESS } from '../actions/interactions';
  7. import Immutable from 'immutable';
  8. const initialState = Immutable.Map({
  9. followers: Immutable.Map(),
  10. following: Immutable.Map(),
  11. suggestions: Immutable.List()
  12. });
  13. export default function userLists(state = initialState, action) {
  14. switch(action.type) {
  15. case FOLLOWERS_FETCH_SUCCESS:
  16. return state.setIn(['followers', action.id], Immutable.List(action.accounts.map(item => item.id)));
  17. case FOLLOWING_FETCH_SUCCESS:
  18. return state.setIn(['following', action.id], Immutable.List(action.accounts.map(item => item.id)));
  19. case SUGGESTIONS_FETCH_SUCCESS:
  20. return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id)));
  21. case REBLOGS_FETCH_SUCCESS:
  22. return state.setIn(['reblogged_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
  23. default:
  24. return state;
  25. }
  26. };