bugfix(rn) sends CONFERENCE_TERMINATED to native after dismissing the ReloadOverlay

This commit is contained in:
tmoldovan8x8 2021-11-10 13:34:16 +02:00 committed by GitHub
parent 2d27195652
commit 243aa20912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 53 deletions

View File

@ -17,15 +17,16 @@ import {
getCurrentConference, getCurrentConference,
isRoomValid isRoomValid
} from '../../base/conference'; } from '../../base/conference';
import { LOAD_CONFIG_ERROR } from '../../base/config';
import { import {
CONNECTION_DISCONNECTED, CONNECTION_DISCONNECTED,
CONNECTION_FAILED,
JITSI_CONNECTION_CONFERENCE_KEY, JITSI_CONNECTION_CONFERENCE_KEY,
JITSI_CONNECTION_URL_KEY, JITSI_CONNECTION_URL_KEY,
getURLWithoutParams getURLWithoutParams
} from '../../base/connection'; } from '../../base/connection';
import { JitsiConferenceEvents } from '../../base/lib-jitsi-meet'; import {
isFatalJitsiConferenceError,
isFatalJitsiConnectionError,
JitsiConferenceEvents } from '../../base/lib-jitsi-meet';
import { MEDIA_TYPE } from '../../base/media'; import { MEDIA_TYPE } from '../../base/media';
import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes'; import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes';
import { import {
@ -40,6 +41,7 @@ import { toggleScreensharing } from '../../base/tracks';
import { OPEN_CHAT, CLOSE_CHAT } from '../../chat'; import { OPEN_CHAT, CLOSE_CHAT } from '../../chat';
import { openChat } from '../../chat/actions'; import { openChat } from '../../chat/actions';
import { sendMessage, setPrivateMessageRecipient, closeChat } from '../../chat/actions.any'; import { sendMessage, setPrivateMessageRecipient, closeChat } from '../../chat/actions.any';
import { SET_PAGE_RELOAD_OVERLAY_CANCELED } from '../../overlay/actionTypes';
import { muteLocal } from '../../video-menu/actions'; import { muteLocal } from '../../video-menu/actions';
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture'; import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
@ -114,7 +116,7 @@ MiddlewareRegistry.register(store => next => action => {
// counterpart of the External API (or at least not in the // counterpart of the External API (or at least not in the
// fatality/finality semantics attributed to // fatality/finality semantics attributed to
// conferenceFailed:/onConferenceFailed). // conferenceFailed:/onConferenceFailed).
if (!error.recoverable) { if (!error.recoverable && !isFatalJitsiConnectionError(error) && !isFatalJitsiConferenceError(error)) {
_sendConferenceEvent(store, /* action */ { _sendConferenceEvent(store, /* action */ {
error: _toErrorString(error), error: _toErrorString(error),
...data ...data
@ -154,28 +156,10 @@ MiddlewareRegistry.register(store => next => action => {
break; break;
} }
case CONNECTION_FAILED:
!action.error.recoverable
&& _sendConferenceFailedOnConnectionError(store, action);
break;
case ENTER_PICTURE_IN_PICTURE: case ENTER_PICTURE_IN_PICTURE:
sendEvent(store, type, /* data */ {}); sendEvent(store, type, /* data */ {});
break; break;
case LOAD_CONFIG_ERROR: {
const { error, locationURL } = action;
sendEvent(
store,
CONFERENCE_TERMINATED,
/* data */ {
error: _toErrorString(error),
url: _normalizeUrl(locationURL)
});
break;
}
case OPEN_CHAT: case OPEN_CHAT:
case CLOSE_CHAT: { case CLOSE_CHAT: {
sendEvent( sendEvent(
@ -219,6 +203,16 @@ MiddlewareRegistry.register(store => next => action => {
}); });
break; break;
case SET_PAGE_RELOAD_OVERLAY_CANCELED:
sendEvent(
store,
CONFERENCE_TERMINATED,
/* data */ {
error: _toErrorString(action.error),
url: _normalizeUrl(store.getState()['features/base/connection'].locationURL)
});
break;
case SET_VIDEO_MUTED: case SET_VIDEO_MUTED:
sendEvent( sendEvent(
store, store,
@ -551,36 +545,6 @@ function _sendConferenceEvent(
sendEvent(store, type_, data); sendEvent(store, type_, data);
} }
/**
* Sends {@link CONFERENCE_TERMINATED} event when the {@link CONNECTION_FAILED}
* occurs. It should be done only if the connection fails before the conference
* instance is created. Otherwise the eventual failure event is supposed to be
* emitted by the base/conference feature.
*
* @param {Store} store - The redux store.
* @param {Action} action - The redux action.
* @returns {void}
*/
function _sendConferenceFailedOnConnectionError(store, action) {
const { locationURL } = store.getState()['features/base/connection'];
const { connection } = action;
locationURL
&& forEachConference(
store,
// If there's any conference in the base/conference state then the
// base/conference feature is supposed to emit a failure.
conference => conference.getConnection() !== connection)
&& sendEvent(
store,
CONFERENCE_TERMINATED,
/* data */ {
url: _normalizeUrl(locationURL),
error: action.error.name
});
}
/** /**
* Determines whether to not send a {@code CONFERENCE_LEFT} event to the native * Determines whether to not send a {@code CONFERENCE_LEFT} event to the native
* counterpart of the External API. * counterpart of the External API.

View File

@ -36,3 +36,14 @@ export const TOGGLE_SLOW_GUM_OVERLAY = 'TOGGLE_SLOW_GUM_OVERLAY';
* @public * @public
*/ */
export const SET_FATAL_ERROR = 'SET_FATAL_ERROR'; export const SET_FATAL_ERROR = 'SET_FATAL_ERROR';
/**
* The type of the Redux action which signals that the overlay was canceled.
*
* {
* type: export const SET_PAGE_RELOAD_OVERLAY_CANCELED
* }
* @public
*/
export const SET_PAGE_RELOAD_OVERLAY_CANCELED
= 'SET_PAGE_RELOAD_OVERLAY_CANCELED';

View File

@ -3,6 +3,7 @@
import { import {
MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED, MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
SET_FATAL_ERROR, SET_FATAL_ERROR,
SET_PAGE_RELOAD_OVERLAY_CANCELED,
TOGGLE_SLOW_GUM_OVERLAY TOGGLE_SLOW_GUM_OVERLAY
} from './actionTypes'; } from './actionTypes';
@ -63,3 +64,20 @@ export function setFatalError(fatalError: Object) {
fatalError fatalError
}; };
} }
/**
* The action indicates that the overlay was canceled.
*
* @param {Object} error - The error that caused the display of the overlay.
*
* @returns {{
* type: SET_PAGE_RELOAD_OVERLAY_CANCELED,
* error: ?Error
* }}
*/
export function setPageReloadOverlayCanceled(error: Object) {
return {
type: SET_PAGE_RELOAD_OVERLAY_CANCELED,
error
};
}

View File

@ -33,6 +33,11 @@ export type Props = {
dispatch: Dispatch<any>, dispatch: Dispatch<any>,
/**
* The error that caused the display of the overlay.
*/
error: Error,
/** /**
* The indicator which determines whether the reload was caused by network * The indicator which determines whether the reload was caused by network
* failure. * failure.
@ -273,6 +278,7 @@ export default class AbstractPageReloadOverlay<P: Props>
* @protected * @protected
* @returns {{ * @returns {{
* details: Object, * details: Object,
* error: ?Error,
* isNetworkFailure: boolean, * isNetworkFailure: boolean,
* reason: string * reason: string
* }} * }}
@ -284,6 +290,7 @@ export function abstractMapStateToProps(state: Object) {
return { return {
details: fatalError && fatalError.details, details: fatalError && fatalError.details,
error: fatalError,
isNetworkFailure: isNetworkFailure:
fatalError === configError || fatalError === connectionError, fatalError === configError || fatalError === connectionError,
reason: fatalError && (fatalError.message || fatalError.name) reason: fatalError && (fatalError.message || fatalError.name)

View File

@ -9,7 +9,7 @@ import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n'; import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux'; import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles'; import { StyleType } from '../../../base/styles';
import { setFatalError } from '../../actions'; import { setFatalError, setPageReloadOverlayCanceled } from '../../actions';
import AbstractPageReloadOverlay, { import AbstractPageReloadOverlay, {
abstractMapStateToProps, abstractMapStateToProps,
type Props as AbstractProps type Props as AbstractProps
@ -58,6 +58,7 @@ class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
*/ */
_onCancel() { _onCancel() {
clearInterval(this._interval); clearInterval(this._interval);
this.props.dispatch(setPageReloadOverlayCanceled(this.props.error));
this.props.dispatch(setFatalError(undefined)); this.props.dispatch(setFatalError(undefined));
this.props.dispatch(appNavigate(undefined)); this.props.dispatch(appNavigate(undefined));
} }