From aef6e33c91e0f2e9cf4b37eca1fba55dbeba8e0e Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Wed, 1 Mar 2017 21:33:49 -0600 Subject: [PATCH] [RN] Fix remote JS debugging --- react/features/app/actions.js | 1 - react/features/app/components/AbstractApp.js | 32 +++++++++---------- react/features/app/components/App.web.js | 6 ++-- .../unsupported-browser/middleware.js | 3 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/react/features/app/actions.js b/react/features/app/actions.js index 26a995c1a..f2455ff47 100644 --- a/react/features/app/actions.js +++ b/react/features/app/actions.js @@ -43,7 +43,6 @@ export function appNavigate(uri) { domain = _parseURIString(state['features/app'].app._getDefaultURL()) .domain; - } // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js index b3cb4f664..f4818d75e 100644 --- a/react/features/app/components/AbstractApp.js +++ b/react/features/app/components/AbstractApp.js @@ -125,6 +125,21 @@ export class AbstractApp extends Component { dispatch(appWillUnmount(this)); } + /** + * Gets a Location object from the window with information about the current + * location of the document. Explicitly defined to allow extenders to + * override because React Native does not usually have a location property + * on its window unless debugging remotely in which case the browser that is + * the remote debugger will provide a location property on the window. + * + * @public + * @returns {Location} A Location object with information about the current + * location of the document. + */ + getWindowLocation() { + return undefined; + } + /** * Implements React's {@link Component#render()}. * @@ -226,7 +241,7 @@ export class AbstractApp extends Component { // If the execution environment provides a Location abstraction, then // this App at already at that location but it must be made aware of the // fact. - const windowLocation = this._getWindowLocation(); + const windowLocation = this.getWindowLocation(); if (windowLocation) { const href = windowLocation.toString(); @@ -272,21 +287,6 @@ export class AbstractApp extends Component { return store; } - /** - * Gets a Location object from the window with information about the current - * location of the document. Explicitly defined to allow extenders to - * override because React Native does not usually have a location property - * on its window unless debugging remotely in which case the browser that is - * the remote debugger will provide a location property on the window. - * - * @protected - * @returns {Location} A Location object with information about the current - * location of the document. - */ - _getWindowLocation() { - return undefined; - } - /** * Creates a Redux store to be used by this AbstractApp if such as store is * not defined by the consumer of this AbstractApp through its diff --git a/react/features/app/components/App.web.js b/react/features/app/components/App.web.js index 38cdfed01..c2dc8d129 100644 --- a/react/features/app/components/App.web.js +++ b/react/features/app/components/App.web.js @@ -52,7 +52,7 @@ export class App extends AbstractApp { * * @inheritdoc */ - _getWindowLocation() { + getWindowLocation() { return window.location; } @@ -63,7 +63,7 @@ export class App extends AbstractApp { * @returns {string} The context root of window.location i.e. this Web App. */ _getWindowLocationContextRoot() { - const pathname = this._getWindowLocation().pathname; + const pathname = this.getWindowLocation().pathname; const contextRootEndIndex = pathname.lastIndexOf('/'); return ( @@ -93,7 +93,7 @@ export class App extends AbstractApp { path = this._routePath2WindowLocationPathname(path); // Navigate to the specified Route. - const windowLocation = this._getWindowLocation(); + const windowLocation = this.getWindowLocation(); if (windowLocation.pathname === path) { // The browser is at the specified path already and what remains is diff --git a/react/features/unsupported-browser/middleware.js b/react/features/unsupported-browser/middleware.js index 011614756..76b473203 100644 --- a/react/features/unsupported-browser/middleware.js +++ b/react/features/unsupported-browser/middleware.js @@ -40,7 +40,8 @@ function _setWebRTCReady(store, next, action) { // execution enviroment has changed. The current location is not necessarily // available through window.location (e.g. on mobile) but the following // works at the time of this writing. - const windowLocation = window.location; + const windowLocation + = store.getState()['features/app'].app.getWindowLocation(); if (windowLocation) { const href = windowLocation.href;