2020-12-08 05:07:04 +00:00
|
|
|
import {
|
|
|
|
DECK_CONNECT,
|
|
|
|
DECK_DISCONNECT,
|
2020-12-16 22:29:06 +00:00
|
|
|
DECK_SEARCH_USERS_CLEAR,
|
|
|
|
DECK_SEARCH_USERS_SUCCESS,
|
2020-12-08 05:07:04 +00:00
|
|
|
} from '../actions/deck'
|
2020-12-16 22:29:06 +00:00
|
|
|
import {
|
|
|
|
Map as ImmutableMap,
|
|
|
|
List as ImmutableList,
|
|
|
|
} from 'immutable'
|
2020-12-08 05:07:04 +00:00
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
|
|
|
connected: false,
|
2020-12-16 22:29:06 +00:00
|
|
|
accountSuggestions: ImmutableList(),
|
2020-12-08 05:07:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
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())
|
2020-12-08 05:07:04 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|