2022-08-08 11:06:29 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
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,
|
2022-05-23 15:02:14 +00:00
|
|
|
SET_DYNAMIC_BRANDING_READY,
|
|
|
|
UNSET_DYNAMIC_BRANDING
|
2020-09-16 10:44:49 +00:00
|
|
|
} from './actionTypes';
|
2020-05-22 06:36:24 +00:00
|
|
|
|
2022-05-23 15:02:14 +00:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-08-08 11:06:29 +00:00
|
|
|
export interface IDynamicBrandingState {
|
|
|
|
avatarBackgrounds: string[];
|
|
|
|
backgroundColor: string;
|
|
|
|
backgroundImageUrl: string;
|
|
|
|
customizationFailed: boolean;
|
|
|
|
customizationReady: boolean;
|
|
|
|
defaultBranding: boolean;
|
|
|
|
didPageUrl: string;
|
|
|
|
inviteDomain: string;
|
2022-09-08 09:52:36 +00:00
|
|
|
labels: Object | null;
|
2022-08-08 11:06:29 +00:00
|
|
|
logoClickUrl: string;
|
|
|
|
logoImageUrl: string;
|
|
|
|
muiBrandedTheme?: boolean;
|
|
|
|
premeetingBackground: string;
|
2022-12-08 14:02:31 +00:00
|
|
|
showGiphyIntegration?: boolean;
|
2022-08-08 11:06:29 +00:00
|
|
|
useDynamicBrandingData: boolean;
|
|
|
|
virtualBackgrounds: Array<Image>;
|
|
|
|
}
|
|
|
|
|
2020-05-22 06:36:24 +00:00
|
|
|
/**
|
|
|
|
* Reduces redux actions for the purposes of the feature {@code dynamic-branding}.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IDynamicBrandingState>(STORE_NAME, (state = DEFAULT_STATE, action): IDynamicBrandingState => {
|
2020-05-22 06:36:24 +00:00
|
|
|
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,
|
2022-12-08 14:02:31 +00:00
|
|
|
showGiphyIntegration,
|
2021-09-10 07:00:54 +00:00
|
|
|
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,
|
2022-12-08 14:02:31 +00:00
|
|
|
showGiphyIntegration,
|
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
|
|
|
|
};
|
2022-05-23 15:02:14 +00:00
|
|
|
|
|
|
|
case UNSET_DYNAMIC_BRANDING:
|
|
|
|
return DEFAULT_STATE;
|
2020-05-22 06:36:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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}}
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
function formatImages(images: Array<string> | Array<{ src: string; tooltip?: string; }>): Array<Image> {
|
2021-09-10 07:00:54 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|