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,
|
|
|
|
failure: false,
|
2018-04-24 19:34:03 +00:00
|
|
|
server: '',
|
2018-08-10 17:26:36 +00:00
|
|
|
loading: true,
|
|
|
|
adding: true
|
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,
|
2018-08-10 17:26:36 +00:00
|
|
|
failure: false,
|
|
|
|
adding: true
|
2017-09-01 19:42:50 +00:00
|
|
|
};
|
|
|
|
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,
|
2018-08-10 17:26:36 +00:00
|
|
|
adding: false
|
2018-04-24 19:34:03 +00:00
|
|
|
};
|
2018-08-01 19:35:06 +00:00
|
|
|
case SERVER.SELECT_REQUEST:
|
2018-04-24 19:34:03 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
server: action.server,
|
2018-08-10 17:26:36 +00:00
|
|
|
connecting: true,
|
|
|
|
connected: false,
|
2018-08-01 19:35:06 +00:00
|
|
|
loading: true
|
|
|
|
};
|
|
|
|
case SERVER.SELECT_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
server: action.server,
|
2018-08-10 17:26:36 +00:00
|
|
|
connecting: false,
|
|
|
|
connected: true,
|
2018-08-01 19:35:06 +00:00
|
|
|
loading: false
|
2018-04-24 19:34:03 +00:00
|
|
|
};
|
2017-08-18 21:30:16 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|