From e4c3e15791da7b31f9d6b9063813ab7ac6a0d6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 7 Feb 2019 15:37:35 +0100 Subject: [PATCH] rn: simplified code There is no need for AbstractApp to require some getWindowLocation function. It's only used in one place and we even polyfill it on mobile. Thus replace it's usage with more specific functions. --- react/features/app/components/AbstractApp.js | 16 ---------- react/features/app/components/App.web.js | 10 ------ react/features/app/functions.any.js | 32 -------------------- react/features/app/functions.native.js | 18 ++++++++++- react/features/app/functions.web.js | 22 +++++++++++++- 5 files changed, 38 insertions(+), 60 deletions(-) delete mode 100644 react/features/app/functions.any.js diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js index 1c890fab5..0e41d2198 100644 --- a/react/features/app/components/AbstractApp.js +++ b/react/features/app/components/AbstractApp.js @@ -79,22 +79,6 @@ export class AbstractApp extends BaseApp { }); } - /** - * Gets a {@code 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 {@code Location} object with information about the - * current location of the document. - */ - getWindowLocation() { - return undefined; - } - /** * Creates an extra {@link ReactElement}s to be added (unconditionaly) * alongside the main element. diff --git a/react/features/app/components/App.web.js b/react/features/app/components/App.web.js index 5e5bcae7a..91fdfee0e 100644 --- a/react/features/app/components/App.web.js +++ b/react/features/app/components/App.web.js @@ -17,16 +17,6 @@ import { AbstractApp } from './AbstractApp'; * @extends AbstractApp */ export class App extends AbstractApp { - /** - * Gets a Location object from the window with information about the current - * location of the document. - * - * @inheritdoc - */ - getWindowLocation() { - return window.location; - } - /** * Overrides the parent method to inject {@link AtlasKitThemeProvider} as * the top most component. diff --git a/react/features/app/functions.any.js b/react/features/app/functions.any.js deleted file mode 100644 index fbabebcde..000000000 --- a/react/features/app/functions.any.js +++ /dev/null @@ -1,32 +0,0 @@ -// @flow - -import { getAppProp } from '../base/app'; -import { toState } from '../base/redux'; -import { getServerURL } from '../base/settings'; - -/** - * Retrieves the default URL for the app. This can either come from a prop to - * the root App component or be configured in the settings. - * - * @param {Function|Object} stateful - The redux store or {@code getState} - * function. - * @returns {string} - Default URL for the app. - */ -export function getDefaultURL(stateful: Function | Object) { - const state = toState(stateful); - const { app } = state['features/base/app']; - - // If the execution environment provides a Location abstraction (e.g. a Web - // browser), then we'll presume it's the one and only base URL it can be on. - const windowLocation = app.getWindowLocation(); - - if (windowLocation) { - const href = windowLocation.toString(); - - if (href) { - return href; - } - } - - return getAppProp(state, 'defaultURL') || getServerURL(state); -} diff --git a/react/features/app/functions.native.js b/react/features/app/functions.native.js index 6b0e8033e..b28ebe264 100644 --- a/react/features/app/functions.native.js +++ b/react/features/app/functions.native.js @@ -2,7 +2,23 @@ import { NativeModules } from 'react-native'; -export * from './functions.any'; +import { getAppProp } from '../base/app'; +import { toState } from '../base/redux'; +import { getServerURL } from '../base/settings'; + +/** + * Retrieves the default URL for the app. This can either come from a prop to + * the root App component or be configured in the settings. + * + * @param {Function|Object} stateful - The redux store or {@code getState} + * function. + * @returns {string} - Default URL for the app. + */ +export function getDefaultURL(stateful: Function | Object) { + const state = toState(stateful); + + return getAppProp(state, 'defaultURL') || getServerURL(state); +} /** * Returns application name. diff --git a/react/features/app/functions.web.js b/react/features/app/functions.web.js index c2006d46b..b389034b7 100644 --- a/react/features/app/functions.web.js +++ b/react/features/app/functions.web.js @@ -1,9 +1,29 @@ // @flow -export * from './functions.any'; +import { toState } from '../base/redux'; +import { getServerURL } from '../base/settings'; declare var interfaceConfig: Object; +/** + * Retrieves the default URL for the app. This can either come from a prop to + * the root App component or be configured in the settings. + * + * @param {Function|Object} stateful - The redux store or {@code getState} + * function. + * @returns {string} - Default URL for the app. + */ +export function getDefaultURL(stateful: Function | Object) { + const state = toState(stateful); + const { href } = window.location; + + if (href) { + return href; + } + + return getServerURL(state); +} + /** * Returns application name. *