import { combineReducers } from 'redux' ; import { robotLogsReducer } from './robot-logs/reducer' ; import type { Action } from '../types' ; import type { ShellUpdateState } from './types' ; const INITIAL_STATE = { checking : false , downloading : false , available : false , downloaded : false , info : null , error : null , } ; export function shellUpdateReducer ( state = INITIAL_STATE , action ) { switch ( action . type ) { case 'shell:CHECK_UPDATE' : { return { ... state , checking : true , error : null } ; } case 'shell:CHECK_UPDATE_RESULT' : { return { ... state , ... action . payload , checking : false } ; } case 'shell:DOWNLOAD_UPDATE' : { return { ... state , downloading : true , error : null } ; } case 'shell:DOWNLOAD_UPDATE_RESULT' : { return { ... state , downloading : false , error : action . payload . error || null , downloaded : ! action . payload . error , } ; } } return state ; } export const shellReducer = combineReducers < any , Action > ( { update : shellUpdateReducer , robotLogs : robotLogsReducer , } ) ;