@@ -29,6 +29,7 @@ import {
2929import { executeSystemCommand } from 'shared/modules/commands/commandsDuck'
3030import {
3131 getInitCmd ,
32+ getPlayImplicitInitCommands ,
3233 getSettings ,
3334 getCmdChar ,
3435 getConnectionTimeout
@@ -56,6 +57,8 @@ export const UPDATE_AUTH_ENABLED = NAME + '/UPDATE_AUTH_ENABLED'
5657export const SWITCH_CONNECTION = NAME + '/SWITCH_CONNECTION'
5758export const SWITCH_CONNECTION_SUCCESS = NAME + '/SWITCH_CONNECTION_SUCCESS'
5859export const SWITCH_CONNECTION_FAILED = NAME + '/SWITCH_CONNECTION_FAILED'
60+ export const INITIAL_SWITCH_CONNECTION_FAILED =
61+ NAME + '/INITIAL_SWITCH_CONNECTION_FAILED'
5962export const VERIFY_CREDENTIALS = NAME + '/VERIFY_CREDENTIALS'
6063export const USE_DB = NAME + '/USE_DB'
6164
@@ -429,19 +432,27 @@ export const startupConnectEpic = (action$, store) => {
429432export const startupConnectionSuccessEpic = ( action$ , store ) => {
430433 return action$
431434 . ofType ( STARTUP_CONNECTION_SUCCESS )
432- . do ( ( ) =>
433- store . dispatch (
434- executeSystemCommand ( getCmdChar ( store . getState ( ) ) + 'server status' )
435- )
436- )
437- . mapTo ( executeSystemCommand ( getInitCmd ( store . getState ( ) ) ) ) // execute initCmd from settings
435+ . do ( ( ) => {
436+ if ( getPlayImplicitInitCommands ( store . getState ( ) ) ) {
437+ store . dispatch (
438+ executeSystemCommand ( getCmdChar ( store . getState ( ) ) + 'server status' )
439+ )
440+ store . dispatch ( executeSystemCommand ( getInitCmd ( store . getState ( ) ) ) )
441+ }
442+ } )
443+ . mapTo ( { type : 'NOOP' } )
438444}
439445export const startupConnectionFailEpic = ( action$ , store ) => {
440446 return action$
441447 . ofType ( STARTUP_CONNECTION_FAILED )
442- . mapTo (
443- executeSystemCommand ( getCmdChar ( store . getState ( ) ) + 'server connect' )
444- )
448+ . do ( ( ) => {
449+ if ( getPlayImplicitInitCommands ( store . getState ( ) ) ) {
450+ store . dispatch (
451+ executeSystemCommand ( getCmdChar ( store . getState ( ) ) + 'server connect' )
452+ )
453+ }
454+ } )
455+ . mapTo ( { type : 'NOOP' } )
445456}
446457
447458let lastActiveConnectionId = null
@@ -624,6 +635,21 @@ export const switchConnectionFailEpic = (action$, store) => {
624635 executeSystemCommand ( getCmdChar ( store . getState ( ) ) + 'server switch fail' )
625636 )
626637}
638+ export const initialSwitchConnectionFailEpic = ( action$ , store ) => {
639+ return action$
640+ . ofType ( INITIAL_SWITCH_CONNECTION_FAILED )
641+ . do ( ( ) => {
642+ store . dispatch ( updateConnectionState ( DISCONNECTED_STATE ) )
643+ if ( getPlayImplicitInitCommands ( store . getState ( ) ) ) {
644+ store . dispatch (
645+ executeSystemCommand (
646+ getCmdChar ( store . getState ( ) ) + 'server switch fail'
647+ )
648+ )
649+ }
650+ } )
651+ . mapTo ( { type : 'NOOP' } )
652+ }
627653
628654export const retainCredentialsSettingsEpic = ( action$ , store ) => {
629655 return action$
0 commit comments