2017-08-18 21:30:16 +00:00
|
|
|
import { SERVER } from '../actions/actionsTypes';
|
|
|
|
|
2017-09-01 19:42:50 +00:00
|
|
|
const initialState = {
|
|
|
|
connecting: false,
|
|
|
|
connected: false,
|
|
|
|
errorMessage: '',
|
|
|
|
failure: false,
|
2017-12-27 15:22:06 +00:00
|
|
|
server: {}
|
2017-09-01 19:42:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default function server(state = initialState, action) {
|
2017-08-18 21:30:16 +00:00
|
|
|
switch (action.type) {
|
2017-09-01 19:42:50 +00:00
|
|
|
case SERVER.REQUEST:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: true,
|
|
|
|
failure: false
|
|
|
|
};
|
|
|
|
case SERVER.SUCCESS:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: false,
|
|
|
|
connected: true,
|
|
|
|
failure: false
|
|
|
|
};
|
|
|
|
case SERVER.FAILURE:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: false,
|
|
|
|
connected: false,
|
|
|
|
failure: true,
|
|
|
|
errorMessage: action.err
|
|
|
|
};
|
2017-08-18 21:30:16 +00:00
|
|
|
case SERVER.SELECT:
|
2017-09-01 19:42:50 +00:00
|
|
|
return { ...state, server: action.server };
|
2017-08-18 21:30:16 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|