mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-15 08:47:47 +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.
83 lines
1.9 KiB
JavaScript
83 lines
1.9 KiB
JavaScript
// @flow
|
|
|
|
import { getLogger } from 'jitsi-meet-logger';
|
|
|
|
import { doGetJSON } from '../base/util';
|
|
|
|
import {
|
|
SET_DYNAMIC_BRANDING_DATA,
|
|
SET_DYNAMIC_BRANDING_FAILED,
|
|
SET_DYNAMIC_BRANDING_READY
|
|
} from './actionTypes';
|
|
import { getDynamicBrandingUrl } from './functions';
|
|
|
|
const logger = getLogger(__filename);
|
|
|
|
|
|
/**
|
|
* Fetches custom branding data.
|
|
* If there is no data or the request fails, sets the `customizationReady` flag
|
|
* so the defaults can be displayed.
|
|
*
|
|
* @returns {Function}
|
|
*/
|
|
export function fetchCustomBrandingData() {
|
|
return async function(dispatch: Function, getState: Function) {
|
|
const state = getState();
|
|
const { customizationReady } = state['features/dynamic-branding'];
|
|
|
|
if (!customizationReady) {
|
|
const url = await getDynamicBrandingUrl();
|
|
|
|
if (url) {
|
|
try {
|
|
const res = await doGetJSON(url);
|
|
|
|
return dispatch(setDynamicBrandingData(res));
|
|
} catch (err) {
|
|
logger.error('Error fetching branding data', err);
|
|
|
|
return dispatch(setDynamicBrandingFailed());
|
|
}
|
|
}
|
|
|
|
dispatch(setDynamicBrandingReady());
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Action used to set the user customizations.
|
|
*
|
|
* @param {Object} value - The custom data to be set.
|
|
* @returns {Object}
|
|
*/
|
|
function setDynamicBrandingData(value) {
|
|
return {
|
|
type: SET_DYNAMIC_BRANDING_DATA,
|
|
value
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Action used to signal the branding elements are ready to be displayed.
|
|
*
|
|
* @returns {Object}
|
|
*/
|
|
function setDynamicBrandingReady() {
|
|
return {
|
|
type: SET_DYNAMIC_BRANDING_READY
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Action used to signal the branding request failed.
|
|
*
|
|
* @returns {Object}
|
|
*/
|
|
function setDynamicBrandingFailed() {
|
|
return {
|
|
type: SET_DYNAMIC_BRANDING_FAILED
|
|
};
|
|
}
|