Files
jitsi-meet/react/features/dynamic-branding/functions.js
Vlad Piersec ddcb85a1d8 fix(jaas): Get dynamic branding url from config file
We make the request for dynamic branding as soon as possible so
at the time of the request the config is not yet added to the store.
In order to fix this we get the jass brandingDataUrl &
dynamicBrandingUrl directly from the config.
2021-10-07 11:52:28 +03:00

48 lines
1.2 KiB
JavaScript

// @flow
import { loadConfig } from '../base/lib-jitsi-meet';
/**
* Extracts the fqn part from a path, where fqn represents
* tenant/roomName.
*
* @param {string} path - The URL path.
* @returns {string}
*/
export function extractFqnFromPath() {
const parts = window.location.pathname.split('/');
const len = parts.length;
return parts.length > 2 ? `${parts[len - 2]}/${parts[len - 1]}` : '';
}
/**
* 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;
}