2021-11-16 21:16:18 +00:00
|
|
|
// @flow
|
|
|
|
|
2022-04-08 12:24:58 +00:00
|
|
|
import { loadConfig } from '../base/lib-jitsi-meet/functions';
|
2021-11-16 21:16:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts the fqn part from a path, where fqn represents
|
|
|
|
* tenant/roomName.
|
|
|
|
*
|
2022-03-18 14:16:56 +00:00
|
|
|
* @param {Object} state - A redux state.
|
2021-11-16 21:16:18 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-03-18 14:16:56 +00:00
|
|
|
export function extractFqnFromPath(state?: Object) {
|
|
|
|
let pathname;
|
|
|
|
|
|
|
|
if (window.location.pathname) {
|
|
|
|
pathname = window.location.pathname;
|
|
|
|
} else if (state && state['features/base/connection']) {
|
|
|
|
pathname = state['features/base/connection'].locationURL.pathname;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
const parts = pathname.split('/');
|
2021-11-16 21:16:18 +00:00
|
|
|
const len = parts.length;
|
|
|
|
|
2022-03-03 08:08:08 +00:00
|
|
|
return parts.length > 2 ? `${parts[len - 2]}/${parts[len - 1]}` : parts[1];
|
2021-11-16 21:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the url used for fetching dynamic branding.
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export async function getDynamicBrandingUrl() {
|
|
|
|
const config = await loadConfig(window.location.href);
|
|
|
|
const { dynamicBrandingUrl } = config;
|
|
|
|
|
|
|
|
if (dynamicBrandingUrl) {
|
|
|
|
return dynamicBrandingUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { brandingDataUrl: baseUrl } = config;
|
|
|
|
const fqn = extractFqnFromPath();
|
|
|
|
|
|
|
|
if (baseUrl && fqn) {
|
|
|
|
return `${baseUrl}?conferenceFqn=${encodeURIComponent(fqn)}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector used for getting the load state of the dynamic branding data.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Global state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isDynamicBrandingDataLoaded(state: Object) {
|
|
|
|
return state['features/dynamic-branding'].customizationReady;
|
|
|
|
}
|