import { TActionServer } from '../actions/server';
import { SERVER } from '../actions/actionsTypes';
export interface IServer {
connecting: boolean;
connected: boolean;
failure: boolean;
server: string;
version: string | null;
loading: boolean;
previousServer: string | null;
changingServer: boolean;
}
export const initialState: IServer = {
connecting: false,
connected: false,
failure: false,
server: '',
version: null,
loading: true,
previousServer: null,
changingServer: false
};
export default function server(state = initialState, action: TActionServer): IServer {
switch (action.type) {
case SERVER.REQUEST:
return {
...state,
connecting: true,
failure: false
case SERVER.FAILURE:
failure: true
case SERVER.SELECT_REQUEST:
server: action.server,
version: action.version,
changingServer: action.changeServer
case SERVER.SELECT_SUCCESS:
connected: true,
loading: false,
case SERVER.SELECT_FAILURE:
case SERVER.INIT_ADD:
previousServer: action.previousServer
case SERVER.FINISH_ADD:
previousServer: null
default:
return state;