Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rn,overlay) skip showing reload dialog while leaving the conference #15045

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions react/features/base/dialog/components/native/PageReloadDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
13 changes: 11 additions & 2 deletions react/features/overlay/actions.native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConnectionFailedError } from '../base/connection/types';
import { openDialog } from '../base/dialog/actions';
import PageReloadDialog from '../base/dialog/components/native/PageReloadDialog';

Expand All @@ -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
});
}
6 changes: 5 additions & 1 deletion react/features/overlay/actions.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
35 changes: 15 additions & 20 deletions react/features/overlay/components/web/AbstractPageReloadOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
23 changes: 20 additions & 3 deletions react/features/overlay/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -94,21 +95,37 @@ 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({
...error,
...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'];

console.log(`conference: ${typeof conferenceState.conference}`);
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved
console.log(`leaving: ${typeof conferenceState.leaving}`);
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved

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);
}
}
Expand Down
5 changes: 0 additions & 5 deletions react/features/overlay/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down