2020-05-22 06:36:24 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { ReducerRegistry } from '../base/redux';
|
2021-09-10 07:00:54 +00:00
|
|
|
import { type Image } from '../virtual-background/constants';
|
2020-05-22 06:36:24 +00:00
|
|
|
|
2020-09-16 10:44:49 +00:00
|
|
|
import {
|
|
|
|
SET_DYNAMIC_BRANDING_DATA,
|
|
|
|
SET_DYNAMIC_BRANDING_FAILED,
|
|
|
|
SET_DYNAMIC_BRANDING_READY
|
|
|
|
} from './actionTypes';
|
2020-05-22 06:36:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the redux store/state property which is the root of the redux
|
|
|
|
* state of the feature {@code dynamic-branding}.
|
|
|
|
*/
|
|
|
|
const STORE_NAME = 'features/dynamic-branding';
|
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2021-07-20 11:37:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The pool of avatar backgrounds.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Array<string>}
|
|
|
|
*/
|
|
|
|
avatarBackgrounds: [],
|
|
|
|
|
2020-09-16 10:44:49 +00:00
|
|
|
/**
|
|
|
|
* The custom background color for the LargeVideo.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2020-05-22 06:36:24 +00:00
|
|
|
backgroundColor: '',
|
2020-09-16 10:44:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The custom background image used on the LargeVideo.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2020-05-22 06:36:24 +00:00
|
|
|
backgroundImageUrl: '',
|
2020-09-16 10:44:49 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-24 07:17:40 +00:00
|
|
|
* Flag indicating that the branding data can be displayed.
|
|
|
|
* This is used in order to avoid image flickering / text changing(blipping).
|
2020-09-16 10:44:49 +00:00
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2020-05-22 06:36:24 +00:00
|
|
|
customizationReady: false,
|
2020-09-16 10:44:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag indicating that the dynamic branding data request has failed.
|
|
|
|
* When the request fails there is no logo (JitsiWatermark) displayed.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
customizationFailed: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag indicating that the dynamic branding has not been modified and should use
|
|
|
|
* the default options.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
defaultBranding: true,
|
|
|
|
|
2021-02-24 09:37:14 +00:00
|
|
|
/**
|
|
|
|
* Url for a custom page for DID numbers list.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
didPageUrl: '',
|
|
|
|
|
2020-09-16 10:44:49 +00:00
|
|
|
/**
|
|
|
|
* The custom invite domain.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2020-08-20 07:25:12 +00:00
|
|
|
inviteDomain: '',
|
2020-09-16 10:44:49 +00:00
|
|
|
|
2021-12-07 10:04:33 +00:00
|
|
|
/**
|
|
|
|
* An object containing the mapping between the language and url where the translation
|
|
|
|
* bundle is hosted.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
labels: null,
|
|
|
|
|
2020-09-16 10:44:49 +00:00
|
|
|
/**
|
|
|
|
* The custom url used when the user clicks the logo.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2020-05-22 06:36:24 +00:00
|
|
|
logoClickUrl: '',
|
2020-09-16 10:44:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The custom logo (JitisWatermark).
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
logoImageUrl: '',
|
|
|
|
|
2021-11-15 08:37:54 +00:00
|
|
|
/**
|
|
|
|
* The generated MUI branded theme based on the custom theme json.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
muiBrandedTheme: undefined,
|
|
|
|
|
2021-08-26 09:26:38 +00:00
|
|
|
/**
|
|
|
|
* The lobby/prejoin background.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
premeetingBackground: '',
|
|
|
|
|
2020-09-16 10:44:49 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Flag used to signal if the app should use a custom logo or not.
|
2020-09-16 10:44:49 +00:00
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2021-09-10 07:00:54 +00:00
|
|
|
useDynamicBrandingData: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of images to be used as virtual backgrounds instead of the default ones.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Array<Object>}
|
|
|
|
*/
|
|
|
|
virtualBackgrounds: []
|
2020-05-22 06:36:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces redux actions for the purposes of the feature {@code dynamic-branding}.
|
|
|
|
*/
|
|
|
|
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case SET_DYNAMIC_BRANDING_DATA: {
|
2020-09-16 10:44:49 +00:00
|
|
|
const {
|
2021-08-26 09:26:38 +00:00
|
|
|
avatarBackgrounds,
|
2020-09-16 10:44:49 +00:00
|
|
|
backgroundColor,
|
|
|
|
backgroundImageUrl,
|
|
|
|
defaultBranding,
|
2021-02-24 09:37:14 +00:00
|
|
|
didPageUrl,
|
2020-09-16 10:44:49 +00:00
|
|
|
inviteDomain,
|
2021-12-07 10:04:33 +00:00
|
|
|
labels,
|
2020-09-16 10:44:49 +00:00
|
|
|
logoClickUrl,
|
2021-07-20 11:37:22 +00:00
|
|
|
logoImageUrl,
|
2021-11-15 08:37:54 +00:00
|
|
|
muiBrandedTheme,
|
2021-09-10 07:00:54 +00:00
|
|
|
premeetingBackground,
|
|
|
|
virtualBackgrounds
|
2020-09-16 10:44:49 +00:00
|
|
|
} = action.value;
|
2020-05-22 06:36:24 +00:00
|
|
|
|
|
|
|
return {
|
2021-07-20 11:37:22 +00:00
|
|
|
avatarBackgrounds,
|
2020-05-22 06:36:24 +00:00
|
|
|
backgroundColor,
|
|
|
|
backgroundImageUrl,
|
2020-09-16 10:44:49 +00:00
|
|
|
defaultBranding,
|
2021-02-24 09:37:14 +00:00
|
|
|
didPageUrl,
|
2020-08-20 07:25:12 +00:00
|
|
|
inviteDomain,
|
2021-12-07 10:04:33 +00:00
|
|
|
labels,
|
2020-05-22 06:36:24 +00:00
|
|
|
logoClickUrl,
|
|
|
|
logoImageUrl,
|
2021-11-15 08:37:54 +00:00
|
|
|
muiBrandedTheme,
|
2021-08-26 09:26:38 +00:00
|
|
|
premeetingBackground,
|
2020-09-16 10:44:49 +00:00
|
|
|
customizationFailed: false,
|
|
|
|
customizationReady: true,
|
2021-09-10 07:00:54 +00:00
|
|
|
useDynamicBrandingData: true,
|
|
|
|
virtualBackgrounds: formatImages(virtualBackgrounds || [])
|
2020-09-16 10:44:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_DYNAMIC_BRANDING_FAILED: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
customizationReady: true,
|
|
|
|
customizationFailed: true,
|
|
|
|
useDynamicBrandingData: true
|
2020-05-22 06:36:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_DYNAMIC_BRANDING_READY:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
customizationReady: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|
2021-09-10 07:00:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the branding images into an array of Images objects ready
|
|
|
|
* to be used as virtual backgrounds.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} images -
|
|
|
|
* @private
|
|
|
|
* @returns {{Props}}
|
|
|
|
*/
|
|
|
|
function formatImages(images: Array<string> | Array<Object>): Array<Image> {
|
|
|
|
return images.map((img, i) => {
|
|
|
|
let src;
|
|
|
|
let tooltip;
|
|
|
|
|
|
|
|
if (typeof img === 'object') {
|
|
|
|
({ src, tooltip } = img);
|
|
|
|
} else {
|
|
|
|
src = img;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
id: `branding-${i}`,
|
|
|
|
src,
|
|
|
|
tooltip
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|