import {AppState} from "../state/AppState"; import {isClientAction} from "../../../common/src/actions/ClientAction"; import {clientReducer} from "./ClientReducer"; import {serverReducer} from "./ServerReducer"; import {NetworkAction} from "../../../common/src/actions/NetworkAction"; import {isServerAction} from "../../../common/src/actions/ServerAction"; import {exhaustivenessCheck} from "../../../common/src/util/TypeUtils"; export function networkReducer(oldState: AppState, action: NetworkAction): AppState { if (isClientAction(action)) { const newState = clientReducer(oldState.network, action) if (newState === oldState.network) { return oldState } return { ...oldState, network: newState } } else if (isServerAction(action)) { return serverReducer(oldState, action) } exhaustivenessCheck(action) }