Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(rn,overlay) skip showing reload dialog while leaving the conference (#15045)
Saúl Ibarra Corretgé756c4afbdd95
diff --git a/react/features/base/dialog/components/native/PageReloadDialog.tsx b/react/features/base/dialog/components/native/PageReloadDialog.tsxindex 57baab4637..2a85c707fb 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<IPageReloadDialogProps, IPageReloadDialogState> {+class PageReloadDialog extends Component<IProps, IPageReloadDialogState> {_interval?: number;_timeoutSeconds: number;@@ -48,7 +51,7 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial* instance is to be initialized.* @public*/- constructor(props: IPageReloadDialogProps) {+ constructor(props: IProps) {super(props);this._timeoutSeconds = 10 + randomInt(0, 20);@@ -184,23 +187,18 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial* Maps (parts of) the redux state to the associated component's props.** @param {Object} state - The redux state.+ * @param {IProps} ownProps - The own props of the component.* @protected* @returns {{* isNetworkFailure: boolean,* reason: string* }}*/-function mapStateToProps(state: IReduxState) {- const { error: conferenceError } = state['features/base/conference'];- const { error: configError } = state['features/base/config'];- const { error: connectionError } = state['features/base/connection'];- const { fatalError } = state['features/overlay'];-+function mapStateToProps(state: IReduxState, ownProps: IProps) {+ const { conferenceError, configError, connectionError } = ownProps;const fatalConnectionError= connectionError && isFatalJitsiConnectionError(connectionError);- const fatalConfigError = fatalError === configError;-- const isNetworkFailure = Boolean(fatalConfigError || fatalConnectionError);+ const isNetworkFailure = Boolean(configError || fatalConnectionError);let reason;diff --git a/react/features/overlay/actions.native.ts b/react/features/overlay/actions.native.tsindex 0cb176e9c1..0308eb9269 100644--- a/react/features/overlay/actions.native.ts+++ b/react/features/overlay/actions.native.ts@@ -1,3 +1,4 @@+import { ConnectionFailedError } from '../base/connection/types';import { openDialog } from '../base/dialog/actions';import PageReloadDialog from '../base/dialog/components/native/PageReloadDialog';@@ -22,8 +23,16 @@ export function mediaPermissionPromptVisibilityChanged(_isVisible: boolean, _bro/*** Opens {@link PageReloadDialog}.*+ * @param {Error} conferenceError - The conference error that caused the reload.+ * @param {Error} configError - The conference error that caused the reload.+ * @param {Error} connectionError - The conference error that caused the reload.* @returns {Function}*/-export function openPageReloadDialog() {- return openDialog(PageReloadDialog);+export function openPageReloadDialog(+ conferenceError?: Error, configError?: Error, connectionError?: ConnectionFailedError) {+ return openDialog(PageReloadDialog, {+ conferenceError,+ configError,+ connectionError+ });}diff --git a/react/features/overlay/actions.web.ts b/react/features/overlay/actions.web.tsindex 0cd61c21ac..88d729f150 100644--- a/react/features/overlay/actions.web.ts+++ b/react/features/overlay/actions.web.ts@@ -25,8 +25,12 @@ export function mediaPermissionPromptVisibilityChanged(isVisible: boolean, brows/*** Opens {@link PageReloadDialog}.*+ * @param {any} _dummy1 - N/A for web.+ * @param {any} _dummy2 - N/A for web.+ * @param {any} _dummy3 - N/A for web.+ ** @returns {Function}*/-export function openPageReloadDialog(): any {+export function openPageReloadDialog(_dummy1: any, _dummy2: any, _dummy3: any): any {// Dummy}diff --git a/react/features/overlay/components/web/AbstractPageReloadOverlay.tsx b/react/features/overlay/components/web/AbstractPageReloadOverlay.tsxindex c14b790bf0..9386d7b0e4 100644--- a/react/features/overlay/components/web/AbstractPageReloadOverlay.tsx+++ b/react/features/overlay/components/web/AbstractPageReloadOverlay.tsx@@ -258,29 +258,24 @@ export default class AbstractPageReloadOverlay<P extends IProps>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.tsindex 58df9eed49..0a7ae30826 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-conditionif (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.tsindex 2987d3b69d..b997cb583e 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;}