fix(reload): Preserve URL params on reload/redirect.
This commit is contained in:
parent
fd0749000e
commit
df754f4f41
|
@ -7,7 +7,7 @@ import Recorder from './modules/recorder/Recorder';
|
||||||
|
|
||||||
import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
|
import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
|
||||||
|
|
||||||
import { reload, reportError } from './modules/util/helpers';
|
import { reportError } from './modules/util/helpers';
|
||||||
|
|
||||||
import * as RemoteControlEvents
|
import * as RemoteControlEvents
|
||||||
from './service/remotecontrol/RemoteControlEvents';
|
from './service/remotecontrol/RemoteControlEvents';
|
||||||
|
@ -24,6 +24,10 @@ import {
|
||||||
initAnalytics,
|
initAnalytics,
|
||||||
sendAnalytics
|
sendAnalytics
|
||||||
} from './react/features/analytics';
|
} from './react/features/analytics';
|
||||||
|
import {
|
||||||
|
redirectWithStoredParams,
|
||||||
|
reloadWithStoredParams
|
||||||
|
} from './react/features/app';
|
||||||
|
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
|
@ -216,7 +220,7 @@ function maybeRedirectToWelcomePage(options) {
|
||||||
// save whether current user is guest or not, before navigating
|
// save whether current user is guest or not, before navigating
|
||||||
// to close page
|
// to close page
|
||||||
window.sessionStorage.setItem('guest', isGuest);
|
window.sessionStorage.setItem('guest', isGuest);
|
||||||
assignWindowLocationPathname(`static/${
|
redirectToStaticPage(`static/${
|
||||||
options.feedbackSubmitted ? 'close.html' : 'close2.html'}`);
|
options.feedbackSubmitted ? 'close.html' : 'close2.html'}`);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -234,7 +238,7 @@ function maybeRedirectToWelcomePage(options) {
|
||||||
if (config.enableWelcomePage) {
|
if (config.enableWelcomePage) {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
assignWindowLocationPathname('./');
|
APP.store.dispatch(redirectWithStoredParams('/'));
|
||||||
},
|
},
|
||||||
3000);
|
3000);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +254,7 @@ function maybeRedirectToWelcomePage(options) {
|
||||||
* assigning it to window.location.pathname.
|
* assigning it to window.location.pathname.
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function assignWindowLocationPathname(pathname) {
|
function redirectToStaticPage(pathname) {
|
||||||
const windowLocation = window.location;
|
const windowLocation = window.location;
|
||||||
let newPathname = pathname;
|
let newPathname = pathname;
|
||||||
|
|
||||||
|
@ -310,7 +314,7 @@ class ConferenceConnector {
|
||||||
|
|
||||||
case JitsiConferenceErrors.NOT_ALLOWED_ERROR: {
|
case JitsiConferenceErrors.NOT_ALLOWED_ERROR: {
|
||||||
// let's show some auth not allowed page
|
// let's show some auth not allowed page
|
||||||
assignWindowLocationPathname('static/authError.html');
|
redirectToStaticPage('static/authError.html');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +382,7 @@ class ConferenceConnector {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS:
|
case JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS:
|
||||||
reload();
|
APP.store.dispatch(reloadWithStoredParams());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -66,6 +66,8 @@ function doExternalAuth(room, lockPassword) {
|
||||||
* @param {string} [roomName] the name of the conference room.
|
* @param {string} [roomName] the name of the conference room.
|
||||||
*/
|
*/
|
||||||
function redirectToTokenAuthService(roomName) {
|
function redirectToTokenAuthService(roomName) {
|
||||||
|
// FIXME: This method will not preserve the other URL params that were
|
||||||
|
// originally passed.
|
||||||
UIUtil.redirect(getTokenAuthUrl(roomName, false));
|
UIUtil.redirect(getTokenAuthUrl(roomName, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,14 @@ const UIUtil = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects to a given URL.
|
||||||
|
*
|
||||||
|
* @param {string} url - The redirect URL.
|
||||||
|
* NOTE: Currently used to redirect to 3rd party location for
|
||||||
|
* authentication. In most cases redirectWithStoredParams action must be
|
||||||
|
* used instead of this method in order to preserve curent URL params.
|
||||||
|
*/
|
||||||
redirect(url) {
|
redirect(url) {
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,24 +16,6 @@ export function createDeferred() {
|
||||||
return deferred;
|
return deferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reload page.
|
|
||||||
*/
|
|
||||||
export function reload() {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redirects to a specific new URL by replacing the current location (in the
|
|
||||||
* history).
|
|
||||||
*
|
|
||||||
* @param {string} url the URL pointing to the location where the user should
|
|
||||||
* be redirected to.
|
|
||||||
*/
|
|
||||||
export function replace(url) {
|
|
||||||
window.location.replace(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the error and reports it to the global error handler.
|
* Prints the error and reports it to the global error handler.
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,48 @@ export function appNavigate(uri: ?string) {
|
||||||
_appNavigateToOptionalLocation(dispatch, getState, parseURIString(uri));
|
_appNavigateToOptionalLocation(dispatch, getState, parseURIString(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects to another page generated by replacing the path in the original URL
|
||||||
|
* with the given path.
|
||||||
|
*
|
||||||
|
* @param {(string)} pathname - The path to navigate to.
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
|
export function redirectWithStoredParams(pathname: string) {
|
||||||
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
|
const { locationURL } = getState()['features/base/connection'];
|
||||||
|
const newLocationURL = new URL(locationURL.href);
|
||||||
|
|
||||||
|
newLocationURL.pathname = pathname;
|
||||||
|
window.location.assign(newLocationURL.toString());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the page by restoring the original URL.
|
||||||
|
*
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
|
export function reloadWithStoredParams() {
|
||||||
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
|
const { locationURL } = getState()['features/base/connection'];
|
||||||
|
const windowLocation = window.location;
|
||||||
|
const oldSearchString = windowLocation.search;
|
||||||
|
|
||||||
|
windowLocation.replace(locationURL.toString());
|
||||||
|
|
||||||
|
if (window.self !== window.top
|
||||||
|
&& locationURL.search === oldSearchString) {
|
||||||
|
// NOTE: Assuming that only the hash or search part of the URL will
|
||||||
|
// be changed!
|
||||||
|
// location.reload will not trigger redirect/reload for iframe when
|
||||||
|
// only the hash params are changed. That's why we need to call
|
||||||
|
// reload in addition to replace.
|
||||||
|
windowLocation.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers an in-app navigation to a specific location URI.
|
* Triggers an in-app navigation to a specific location URI.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { appNavigate } from '../app';
|
import { appNavigate, reloadWithStoredParams } from '../app';
|
||||||
import { toURLString } from '../base/util';
|
import { toURLString } from '../base/util';
|
||||||
import { reload, replace } from '../../../modules/util/helpers';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
|
MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
|
||||||
|
@ -44,12 +43,8 @@ export function _reloadNow() {
|
||||||
|
|
||||||
if (navigator.product === 'ReactNative') {
|
if (navigator.product === 'ReactNative') {
|
||||||
dispatch(appNavigate(toURLString(locationURL)));
|
dispatch(appNavigate(toURLString(locationURL)));
|
||||||
} else if (window.self === window.top) {
|
|
||||||
replace(locationURL);
|
|
||||||
} else {
|
} else {
|
||||||
// In an iframe reload with the reload() utility because the
|
dispatch(reloadWithStoredParams());
|
||||||
// replace() utility does not work on an iframe.
|
|
||||||
reload();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue