From 756c4afbdd95eca99e04fe36e7b8f7026e3e6414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 13 Sep 2024 15:09:58 +0200 Subject: [PATCH] fix(rn,overlay) skip showing reload dialog while leaving the conference (#15045) * fix(rn,overlay) skip showing reload dialog while leaving the conference --- .../components/native/PageReloadDialog.tsx | 22 ++++++------ react/features/overlay/actions.native.ts | 13 +++++-- react/features/overlay/actions.web.ts | 6 +++- .../web/AbstractPageReloadOverlay.tsx | 35 ++++++++----------- react/features/overlay/middleware.ts | 20 +++++++++-- react/features/overlay/reducer.ts | 5 --- 6 files changed, 58 insertions(+), 43 deletions(-) diff --git a/react/features/base/dialog/components/native/PageReloadDialog.tsx b/react/features/base/dialog/components/native/PageReloadDialog.tsx index 57baab46372..2a85c707fb4 100644 --- a/react/features/base/dialog/components/native/PageReloadDialog.tsx +++ b/react/features/base/dialog/components/native/PageReloadDialog.tsx @@ -18,7 +18,10 @@ import ConfirmDialog from './ConfirmDialog'; * The type of the React {@code Component} props of * {@link PageReloadDialog}. */ -interface IPageReloadDialogProps extends WithTranslation { +interface IProps extends WithTranslation { + conferenceError?: Error; + configError?: Error; + connectionError?: Error; dispatch: IStore['dispatch']; isNetworkFailure: boolean; reason?: string; @@ -37,7 +40,7 @@ interface IPageReloadDialogState { * conference is reloaded. * Shows a warning message and counts down towards the re-load. */ -class PageReloadDialog extends Component { +class PageReloadDialog extends Component { _interval?: number; _timeoutSeconds: number; @@ -48,7 +51,7 @@ class PageReloadDialog extends Component export function abstractMapStateToProps(state: IReduxState) { const { error: configError } = state['features/base/config']; const { error: connectionError } = state['features/base/connection']; - const { fatalError } = state['features/overlay']; - - let reason = fatalError && (fatalError.message || fatalError.name); - - if (!reason) { - const { error: conferenceError } = state['features/base/conference']; - - if (conferenceError) { - reason = `error.conference.${conferenceError.name}`; - } else if (configError) { - reason = `error.config.${configError.name}`; - } else if (connectionError) { - reason = `error.connection.${connectionError.name}`; - } else { - logger.error('No reload reason defined!'); - } + const { error: conferenceError } = state['features/base/conference']; + const error = configError || connectionError || conferenceError; + let reason; + + if (conferenceError) { + reason = `error.conference.${conferenceError.name}`; + } else if (configError) { + reason = `error.config.${configError.name}`; + } else if (connectionError) { + reason = `error.connection.${connectionError.name}`; + } else { + logger.error('No reload reason defined!'); } return { - details: fatalError?.details, - error: fatalError, - isNetworkFailure: - fatalError === configError || fatalError === connectionError, + details: undefined, // TODO: revisit this. + error, + isNetworkFailure: Boolean(configError || connectionError), reason }; } diff --git a/react/features/overlay/middleware.ts b/react/features/overlay/middleware.ts index 58df9eed490..0a7ae308260 100644 --- a/react/features/overlay/middleware.ts +++ b/react/features/overlay/middleware.ts @@ -7,6 +7,7 @@ import { import StateListenerRegistry from '../base/redux/StateListenerRegistry'; import { openPageReloadDialog } from './actions'; +import logger from './logger'; /** * Error type. Basically like Error, but augmented with a recoverable property. @@ -94,12 +95,12 @@ StateListenerRegistry.register( return configError || connectionError || conferenceError; }, /* listener */ (error: ErrorType, store: IStore) => { - const state = store.getState(); - if (!error) { return; } + const state = store.getState(); + // eslint-disable-next-line no-negated-condition if (typeof APP !== 'undefined') { APP.API.notifyError({ @@ -107,8 +108,21 @@ StateListenerRegistry.register( ...getErrorExtraInfo(state, error) }); } else if (RN_NO_RELOAD_DIALOG_ERRORS.indexOf(error.name) === -1 && typeof error.recoverable === 'undefined') { + const { error: conferenceError } = state['features/base/conference']; + const { error: configError } = state['features/base/config']; + const { error: connectionError } = state['features/base/connection']; + const conferenceState = state['features/base/conference']; + + if (conferenceState.leaving) { + logger.info(`Ignoring ${error.name} while leaving conference`); + + return; + } + setTimeout(() => { - store.dispatch(openPageReloadDialog()); + logger.info(`Reloading due to error: ${error.name}`, error); + + store.dispatch(openPageReloadDialog(conferenceError, configError, connectionError)); }, 500); } } diff --git a/react/features/overlay/reducer.ts b/react/features/overlay/reducer.ts index 2987d3b69dd..b997cb583e4 100644 --- a/react/features/overlay/reducer.ts +++ b/react/features/overlay/reducer.ts @@ -6,11 +6,6 @@ import { MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED } from './actionTypes'; export interface IOverlayState { browser?: string; - fatalError?: { - details: Object; - message?: string; - name?: string; - }; isMediaPermissionPromptVisible?: boolean; }