mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 20:47:49 +00:00
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.
48 lines
1.2 KiB
JavaScript
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;
|
|
}
|