From b409c8cc2fa0b88901790e82b02359c9b20d4215 Mon Sep 17 00:00:00 2001 From: Ilya Daynatovich Date: Tue, 14 Feb 2017 16:28:15 -0600 Subject: [PATCH] Fix reload regression --- react/features/base/connection/actions.web.js | 27 ++++++++++++++----- .../features/base/util/interceptComponent.js | 17 +++++++----- .../unsupported-browser/actionTypes.js | 11 ++++++++ react/features/unsupported-browser/actions.js | 22 ++++++++++++++- react/features/unsupported-browser/reducer.js | 10 ++++++- 5 files changed, 72 insertions(+), 15 deletions(-) diff --git a/react/features/base/connection/actions.web.js b/react/features/base/connection/actions.web.js index 3082cbaad..9ffe5e2ec 100644 --- a/react/features/base/connection/actions.web.js +++ b/react/features/base/connection/actions.web.js @@ -9,6 +9,7 @@ import UIEvents from '../../../../service/UI/UIEvents'; import { SET_DOMAIN } from './actionTypes'; import { appNavigate } from '../../app'; +import { setUnsupportedBrowser } from '../../unsupported-browser'; declare var APP: Object; @@ -34,13 +35,6 @@ export function connect() { // XXX For web based version we use conference initialization logic // from the old app (at the moment of writing). return APP.conference.init({ roomName: room }).then(() => { - // If during the conference initialization was defined that browser - // doesn't support WebRTC then we should define which route - // to render. - if (APP.unsupportedBrowser) { - dispatch(appNavigate(room)); - } - if (APP.logCollector) { // Start the LogCollector's periodic "store logs" task APP.logCollector.start(); @@ -82,6 +76,25 @@ export function connect() { APP.UI.hideRingOverLay(); APP.API.notifyConferenceLeft(APP.conference.roomName); logger.error(err); + + dispatch(setUnsupportedBrowser(err)); + + // If during the conference initialization was defined that + // browser doesn't support WebRTC then we should define + // which route to render. + dispatch(appNavigate(room)); + + // Force reinitialization of the conference if WebRTC is ready. + if (err.webRTCReadyPromise) { + err.webRTCReadyPromise.then(() => { + // Setting plugin required flag to false because + // it's already been installed. + dispatch(setUnsupportedBrowser({ + isPluginRequired: false + })); + dispatch(appNavigate(room)); + }); + } }); }; } diff --git a/react/features/base/util/interceptComponent.js b/react/features/base/util/interceptComponent.js index f21d46d50..533f6e422 100644 --- a/react/features/base/util/interceptComponent.js +++ b/react/features/base/util/interceptComponent.js @@ -16,6 +16,7 @@ declare var interfaceConfig: Object; * or not. * * @private + * @param {Object} state - Object containing current Redux state. * @returns {ReactElement|void} * @type {Function[]} */ @@ -27,6 +28,7 @@ const _RULES = [ * app even if the browser supports the app (e.g. Google Chrome with * WebRTC support on Android). * + * @param {Object} state - Redux state of the app. * @returns {UnsupportedMobileBrowser|void} If the rule is satisfied then * we should intercept existing component by UnsupportedMobileBrowser. */ @@ -40,14 +42,17 @@ const _RULES = [ : NoMobileApp); } }, - () => { - if (APP.unsupportedBrowser) { - const { isOldBrowser } = APP.unsupportedBrowser; + state => { + const { + isOldBrowser, + isPluginRequired + } = state['features/unsupported-browser']; - if (isOldBrowser) { - return UnsupportedDesktopBrowser; - } + if (isOldBrowser) { + return UnsupportedDesktopBrowser; + } + if (isPluginRequired) { return PluginRequiredBrowser; } } diff --git a/react/features/unsupported-browser/actionTypes.js b/react/features/unsupported-browser/actionTypes.js index 599fa4d94..55676c6c2 100644 --- a/react/features/unsupported-browser/actionTypes.js +++ b/react/features/unsupported-browser/actionTypes.js @@ -16,3 +16,14 @@ import { Symbol } from '../base/react'; * } */ export const DISMISS_MOBILE_APP_PROMO = Symbol('DISMISS_MOBILE_APP_PROMO'); + +/** + * The type of Redux action which signals to change information about + * unsupported browser in Redux store. + * + * { + * type: SET_UNSUPPORTED_BROWSER, + * unsupportedBrowser: Object + * } + */ +export const SET_UNSUPPORTED_BROWSER = Symbol('SET_UNSUPPORTED_BROWSER'); diff --git a/react/features/unsupported-browser/actions.js b/react/features/unsupported-browser/actions.js index c07c8a7d5..f732b1775 100644 --- a/react/features/unsupported-browser/actions.js +++ b/react/features/unsupported-browser/actions.js @@ -1,4 +1,7 @@ -import { DISMISS_MOBILE_APP_PROMO } from './actionTypes'; +import { + DISMISS_MOBILE_APP_PROMO, + SET_UNSUPPORTED_BROWSER +} from './actionTypes'; /** * Returns a Redux action which signals that the UnsupportedMobileBrowser which @@ -19,3 +22,20 @@ export function dismissMobileAppPromo() { type: DISMISS_MOBILE_APP_PROMO }; } + +/** + * Sets unsupported browser object. + * + * @param {Object} unsupportedBrowser - Object describing the unsupported + * browser. + * @returns {{ + * type: SET_UNSUPPORTED_BROWSER, + * unsupportedBrowser: Object + * }} + */ +export function setUnsupportedBrowser(unsupportedBrowser) { + return { + type: SET_UNSUPPORTED_BROWSER, + unsupportedBrowser + }; +} diff --git a/react/features/unsupported-browser/reducer.js b/react/features/unsupported-browser/reducer.js index 72fc5393a..92a442a26 100644 --- a/react/features/unsupported-browser/reducer.js +++ b/react/features/unsupported-browser/reducer.js @@ -1,6 +1,9 @@ import { ReducerRegistry } from '../base/redux'; -import { DISMISS_MOBILE_APP_PROMO } from './actionTypes'; +import { + DISMISS_MOBILE_APP_PROMO, + SET_UNSUPPORTED_BROWSER +} from './actionTypes'; ReducerRegistry.register( 'features/unsupported-browser', @@ -21,6 +24,11 @@ ReducerRegistry.register( */ mobileAppPromoDismissed: true }; + case SET_UNSUPPORTED_BROWSER: + return { + ...state, + ...action.unsupportedBrowser + }; } return state;