gab-social/app/javascript/gabsocial/reducers/deck.js

30 lines
770 B
JavaScript
Raw Permalink Normal View History

import {
DECK_CONNECT,
DECK_DISCONNECT,
2020-12-16 22:29:06 +00:00
DECK_SEARCH_USERS_CLEAR,
DECK_SEARCH_USERS_SUCCESS,
} from '../actions/deck'
2020-12-16 22:29:06 +00:00
import {
Map as ImmutableMap,
List as ImmutableList,
} from 'immutable'
const initialState = ImmutableMap({
connected: false,
2020-12-16 22:29:06 +00:00
accountSuggestions: ImmutableList(),
})
export default function deck(state = initialState, action) {
switch(action.type) {
case DECK_CONNECT:
return state.set('connected', true)
case DECK_DISCONNECT:
return state.set('connected', false)
2020-12-16 22:29:06 +00:00
case DECK_SEARCH_USERS_SUCCESS:
return state.set('accountSuggestions', ImmutableList(action.accounts.map((item) => item.id)))
case DECK_SEARCH_USERS_CLEAR:
return state.set('accountSuggestions', ImmutableList())
default:
return state;
}
}