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.
35 lines
790 B
JavaScript
35 lines
790 B
JavaScript
// @flow
|
|
|
|
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.
|
|
*
|
|
* @returns {string} The application name.
|
|
*/
|
|
export function getName() {
|
|
return interfaceConfig.APP_NAME;
|
|
}
|