diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index 7b2b9b27d..b7d822b48 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -108,18 +108,34 @@ class ResponsiveWebapp extends Component { } componentDidMount () { + const { + getCurrentPosition, + handleBackButtonPress, + initializeModules, + location, + matchContentToUrl, + parseUrlQueryString, + receivedPositionResponse, + title + } = this.props // Add on back button press behavior. - window.addEventListener('popstate', this.props.handleBackButtonPress) - const { location, title } = this.props + window.addEventListener('popstate', handleBackButtonPress) document.title = title + if (window.location.search) { + // If a URL is detected without hash routing (e.g., http://localhost:9966?sessionId=test), + // window.location.search will have a value. In this case, we need to redirect to the URL root with the + // search reconstructed for use with the hash router. This redirect should cause little disruption. + window.location.href = `${URL_ROOT}/#/${window.location.search}` + return + } if (isMobile()) { // If on mobile browser, check position on load - this.props.getCurrentPosition() + getCurrentPosition() // Also, watch for changes in position on mobile navigator.geolocation.watchPosition( // On success - position => { this.props.receivedPositionResponse({ position }) }, + position => { receivedPositionResponse({ position }) }, // On error error => { console.log('error in watchPosition', error) }, // Options @@ -129,14 +145,14 @@ class ResponsiveWebapp extends Component { // Handle routing to a specific part of the app (e.g. stop viewer) on page // load. (This happens prior to routing request in case special routerId is // set from URL.) - this.props.matchContentToUrl(this.props.location) + matchContentToUrl(location) if (location && location.search) { // Set search params and plan trip if routing enabled and a query exists // in the URL. - this.props.parseUrlQueryString() + parseUrlQueryString() } // Initialize call taker/field trip modules (check for valid auth session). - this.props.initializeModules() + initializeModules() } componentWillUnmount () {