paweldomas 67d7d4fc14 feat(RN): add a fatal error state which is a catch all
Adds a fatal error state on which will depend whether or not the reload
screen is to be displayed. It is to happen when a relevant fatal error
action is not claimed by any feature for error recovery (the recoverable
flag is not set).
2018-06-26 15:39:56 +02:00

28 lines
902 B
JavaScript

// @flow
import { StateListenerRegistry } from '../base/redux';
import { setFatalError } from './actions';
declare var APP: Object;
/**
* State listener which emits the {@code fatalErrorOccurred} action which works
* as a catch all for critical errors which have not been claimed by any other
* feature for error recovery (the recoverable flag is not set).
*/
StateListenerRegistry.register(
/* selector */ state => {
const { error: conferenceError } = state['features/base/conference'];
const { error: configError } = state['features/base/config'];
const { error: connectionError } = state['features/base/connection'];
return configError || connectionError || conferenceError;
},
/* listener */ (error, { dispatch }) => {
error
&& typeof error.recoverable === 'undefined'
&& dispatch(setFatalError(error));
}
);