You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // @flow
  2. import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
  3. import { StateListenerRegistry } from '../base/redux';
  4. import { setFatalError } from './actions';
  5. declare var APP: Object;
  6. /**
  7. * List of errors that are not fatal (or handled differently) so then the overlays won't kick in.
  8. */
  9. const NON_OVERLAY_ERRORS = [
  10. JitsiConferenceErrors.CONFERENCE_ACCESS_DENIED,
  11. JitsiConferenceErrors.CONFERENCE_DESTROYED,
  12. JitsiConferenceErrors.CONNECTION_ERROR
  13. ];
  14. /**
  15. * State listener which emits the {@code fatalErrorOccurred} action which works
  16. * as a catch all for critical errors which have not been claimed by any other
  17. * feature for error recovery (the recoverable flag is not set).
  18. */
  19. StateListenerRegistry.register(
  20. /* selector */ state => {
  21. const { error: conferenceError } = state['features/base/conference'];
  22. const { error: configError } = state['features/base/config'];
  23. const { error: connectionError } = state['features/base/connection'];
  24. return configError || connectionError || conferenceError;
  25. },
  26. /* listener */ (error, { dispatch }) => {
  27. error
  28. && NON_OVERLAY_ERRORS.indexOf(error.name) === -1
  29. && typeof error.recoverable === 'undefined'
  30. && dispatch(setFatalError(error));
  31. }
  32. );