2018-05-23 21:10:04 +00:00
|
|
|
// @flow
|
2017-10-02 23:08:07 +00:00
|
|
|
|
2018-05-23 10:48:59 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2022-03-17 14:13:58 +00:00
|
|
|
import { API_ID } from '../../../modules/API';
|
2017-05-09 05:15:43 +00:00
|
|
|
import { setRoom } from '../base/conference';
|
2018-05-14 20:49:00 +00:00
|
|
|
import {
|
|
|
|
configWillLoad,
|
2019-09-13 14:51:58 +00:00
|
|
|
createFakeConfig,
|
2018-05-14 20:49:00 +00:00
|
|
|
loadConfigError,
|
|
|
|
restoreConfig,
|
|
|
|
setConfig,
|
|
|
|
storeConfig
|
|
|
|
} from '../base/config';
|
2022-03-17 14:13:58 +00:00
|
|
|
import { setLocationURL } from '../base/connection';
|
2022-04-08 12:24:58 +00:00
|
|
|
import { loadConfig } from '../base/lib-jitsi-meet/functions.web';
|
2019-07-01 12:02:25 +00:00
|
|
|
import {
|
2022-06-16 12:27:41 +00:00
|
|
|
appendURLParam,
|
2019-10-04 07:31:22 +00:00
|
|
|
getBackendSafeRoomName,
|
2022-06-16 12:27:41 +00:00
|
|
|
parseURIString,
|
|
|
|
parseURLParams
|
2019-07-01 12:02:25 +00:00
|
|
|
} from '../base/util';
|
2021-07-20 08:58:42 +00:00
|
|
|
import { isVpaasMeeting } from '../jaas/functions';
|
2022-03-17 14:13:58 +00:00
|
|
|
import {
|
|
|
|
clearNotifications,
|
|
|
|
NOTIFICATION_TIMEOUT_TYPE,
|
|
|
|
showNotification
|
|
|
|
} from '../notifications';
|
2018-07-02 21:22:51 +00:00
|
|
|
import { setFatalError } from '../overlay';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-07-01 12:02:25 +00:00
|
|
|
import {
|
2022-03-17 14:13:58 +00:00
|
|
|
redirectToStaticPage,
|
|
|
|
redirectWithStoredParams,
|
|
|
|
reloadWithStoredParams
|
|
|
|
} from './actions.any';
|
|
|
|
import { getDefaultURL, getName } from './functions';
|
2019-08-21 14:50:00 +00:00
|
|
|
import logger from './logger';
|
2018-07-02 21:22:51 +00:00
|
|
|
|
2022-03-17 14:13:58 +00:00
|
|
|
|
2020-03-12 13:53:59 +00:00
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
2022-03-17 14:13:58 +00:00
|
|
|
export * from './actions.any';
|
|
|
|
|
2016-12-14 12:09:29 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2017-05-09 05:15:43 +00:00
|
|
|
* Triggers an in-app navigation to a specific route. Allows navigation to be
|
|
|
|
* abstracted between the mobile/React Native and Web/React applications.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2018-02-27 20:21:28 +00:00
|
|
|
* @param {string|undefined} uri - The URI to which to navigate. It may be a
|
2017-05-09 05:15:43 +00:00
|
|
|
* full URL with an HTTP(S) scheme, a full or partial URI with the app-specific
|
2017-05-26 22:11:33 +00:00
|
|
|
* scheme, or a mere room name.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2017-05-09 05:15:43 +00:00
|
|
|
export function appNavigate(uri: ?string) {
|
2019-04-08 11:18:35 +00:00
|
|
|
return async (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
let location = parseURIString(uri);
|
|
|
|
|
|
|
|
// If the specified location (URI) does not identify a host, use the app's
|
|
|
|
// default.
|
|
|
|
if (!location || !location.host) {
|
|
|
|
const defaultLocation = parseURIString(getDefaultURL(getState));
|
|
|
|
|
|
|
|
if (location) {
|
|
|
|
location.host = defaultLocation.host;
|
|
|
|
|
|
|
|
// FIXME Turn location's host, hostname, and port properties into
|
|
|
|
// setters in order to reduce the risks of inconsistent state.
|
|
|
|
location.hostname = defaultLocation.hostname;
|
|
|
|
location.pathname
|
|
|
|
= defaultLocation.pathname + location.pathname.substr(1);
|
|
|
|
location.port = defaultLocation.port;
|
|
|
|
location.protocol = defaultLocation.protocol;
|
|
|
|
} else {
|
|
|
|
location = defaultLocation;
|
|
|
|
}
|
|
|
|
}
|
2017-04-19 14:52:27 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
location.protocol || (location.protocol = 'https:');
|
2019-04-09 15:53:12 +00:00
|
|
|
const { contextRoot, host, room } = location;
|
2019-04-08 11:18:35 +00:00
|
|
|
const locationURL = new URL(location.toString());
|
2017-08-31 19:16:44 +00:00
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
// There are notifications now that gets displayed after we technically left
|
|
|
|
// the conference, but we're still on the conference screen.
|
|
|
|
dispatch(clearNotifications());
|
|
|
|
|
2019-04-09 15:53:12 +00:00
|
|
|
dispatch(configWillLoad(locationURL, room));
|
2017-04-19 14:52:27 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
let protocol = location.protocol.toLowerCase();
|
2016-12-07 22:06:16 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
// The React Native app supports an app-specific scheme which is sure to not
|
|
|
|
// be supported by fetch.
|
|
|
|
protocol !== 'http:' && protocol !== 'https:' && (protocol = 'https:');
|
2017-01-25 22:11:44 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
const baseURL = `${protocol}//${host}${contextRoot || '/'}`;
|
|
|
|
let url = `${baseURL}config.js`;
|
2017-05-09 05:15:43 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
// XXX In order to support multiple shards, tell the room to the deployment.
|
2022-06-16 12:27:41 +00:00
|
|
|
room && (url = appendURLParam(url, 'room', getBackendSafeRoomName(room)));
|
|
|
|
|
|
|
|
const { release } = parseURLParams(location, true, 'search');
|
|
|
|
|
|
|
|
release && (url = appendURLParam(url, 'release', release));
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-04-08 11:18:35 +00:00
|
|
|
let config;
|
|
|
|
|
2019-05-23 08:17:42 +00:00
|
|
|
// Avoid (re)loading the config when there is no room.
|
|
|
|
if (!room) {
|
2019-04-08 11:18:35 +00:00
|
|
|
config = restoreConfig(baseURL);
|
2019-05-23 08:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!config) {
|
|
|
|
try {
|
|
|
|
config = await loadConfig(url);
|
|
|
|
dispatch(storeConfig(baseURL, config));
|
|
|
|
} catch (error) {
|
|
|
|
config = restoreConfig(baseURL);
|
2017-09-05 20:53:39 +00:00
|
|
|
|
2019-05-23 08:17:42 +00:00
|
|
|
if (!config) {
|
2019-09-13 14:51:58 +00:00
|
|
|
if (room) {
|
|
|
|
dispatch(loadConfigError(error, locationURL));
|
2017-08-28 11:20:53 +00:00
|
|
|
|
2019-09-13 14:51:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is no room (we are on the welcome page), don't fail, just create a fake one.
|
|
|
|
logger.warn('Failed to load config but there is no room, applying a fake one');
|
|
|
|
config = createFakeConfig(baseURL);
|
2019-05-23 08:17:42 +00:00
|
|
|
}
|
2017-09-05 20:53:39 +00:00
|
|
|
}
|
2019-04-08 11:18:35 +00:00
|
|
|
}
|
2017-08-28 11:20:53 +00:00
|
|
|
|
2019-05-22 10:01:58 +00:00
|
|
|
if (getState()['features/base/config'].locationURL !== locationURL) {
|
2019-04-08 11:18:35 +00:00
|
|
|
dispatch(loadConfigError(new Error('Config no longer needed!'), locationURL));
|
2019-05-22 10:01:58 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(setLocationURL(locationURL));
|
|
|
|
dispatch(setConfig(config));
|
|
|
|
dispatch(setRoom(room));
|
2018-05-14 20:49:00 +00:00
|
|
|
};
|
|
|
|
}
|
2019-07-01 12:02:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the welcome page is enabled and redirects to it.
|
|
|
|
* If requested show a thank you dialog before that.
|
|
|
|
* If we have a close page enabled, redirect to it without
|
|
|
|
* showing any other dialog.
|
|
|
|
*
|
|
|
|
* @param {Object} options - Used to decide which particular close page to show
|
|
|
|
* or if close page is disabled, whether we should show the thankyou dialog.
|
|
|
|
* @param {boolean} options.showThankYou - Whether we should
|
|
|
|
* show thank you dialog.
|
|
|
|
* @param {boolean} options.feedbackSubmitted - Whether feedback was submitted.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function maybeRedirectToWelcomePage(options: Object = {}) {
|
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
|
|
|
|
const {
|
|
|
|
enableClosePage
|
|
|
|
} = getState()['features/base/config'];
|
|
|
|
|
|
|
|
// if close page is enabled redirect to it, without further action
|
|
|
|
if (enableClosePage) {
|
2020-08-25 11:57:35 +00:00
|
|
|
if (isVpaasMeeting(getState())) {
|
2022-07-19 09:21:18 +00:00
|
|
|
dispatch(redirectToStaticPage('/'));
|
2020-09-24 08:05:42 +00:00
|
|
|
|
|
|
|
return;
|
2020-08-25 11:57:35 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 20:30:06 +00:00
|
|
|
const { jwt } = getState()['features/base/jwt'];
|
2020-08-25 11:57:35 +00:00
|
|
|
|
2020-08-04 10:46:13 +00:00
|
|
|
let hashParam;
|
2019-07-01 12:02:25 +00:00
|
|
|
|
2020-04-29 06:39:14 +00:00
|
|
|
// save whether current user is guest or not, and pass auth token,
|
|
|
|
// before navigating to close page
|
2020-11-05 20:30:06 +00:00
|
|
|
window.sessionStorage.setItem('guest', !jwt);
|
2020-04-29 06:39:14 +00:00
|
|
|
window.sessionStorage.setItem('jwt', jwt);
|
2019-07-01 12:02:25 +00:00
|
|
|
|
2020-03-12 13:53:59 +00:00
|
|
|
let path = 'close.html';
|
|
|
|
|
|
|
|
if (interfaceConfig.SHOW_PROMOTIONAL_CLOSE_PAGE) {
|
2020-08-04 10:46:13 +00:00
|
|
|
if (Number(API_ID) === API_ID) {
|
|
|
|
hashParam = `#jitsi_meet_external_api_id=${API_ID}`;
|
|
|
|
}
|
2020-03-12 13:53:59 +00:00
|
|
|
path = 'close3.html';
|
|
|
|
} else if (!options.feedbackSubmitted) {
|
|
|
|
path = 'close2.html';
|
|
|
|
}
|
|
|
|
|
2020-08-04 10:46:13 +00:00
|
|
|
dispatch(redirectToStaticPage(`static/${path}`, hashParam));
|
2019-07-01 12:02:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// else: show thankYou dialog only if there is no feedback
|
|
|
|
if (options.showThankYou) {
|
|
|
|
dispatch(showNotification({
|
|
|
|
titleArguments: { appName: getName() },
|
|
|
|
titleKey: 'dialog.thankYou'
|
2021-11-24 11:05:27 +00:00
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
|
2019-07-01 12:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if Welcome page is enabled redirect to welcome page after 3 sec, if
|
|
|
|
// there is a thank you message to be shown, 0.5s otherwise.
|
|
|
|
if (getState()['features/base/config'].enableWelcomePage) {
|
|
|
|
setTimeout(
|
|
|
|
() => {
|
|
|
|
dispatch(redirectWithStoredParams('/'));
|
|
|
|
},
|
|
|
|
options.showThankYou ? 3000 : 500);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-03-17 14:13:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reloads the page.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function reloadNow() {
|
|
|
|
return (dispatch: Dispatch<Function>, getState: Function) => {
|
|
|
|
dispatch(setFatalError(undefined));
|
|
|
|
|
|
|
|
const state = getState();
|
|
|
|
const { locationURL } = state['features/base/connection'];
|
|
|
|
|
|
|
|
logger.info(`Reloading the conference using URL: ${locationURL}`);
|
|
|
|
|
|
|
|
dispatch(reloadWithStoredParams());
|
|
|
|
};
|
|
|
|
}
|