Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(dynamic-branding): apply branding data once, deliver icons separately
Hristo Terezovf0d2cef48d9f
diff --git a/react/features/dynamic-branding/actionTypes.ts b/react/features/dynamic-branding/actionTypes.tsindex d54a663e92..42a2468ff9 100644--- a/react/features/dynamic-branding/actionTypes.ts+++ b/react/features/dynamic-branding/actionTypes.ts@@ -8,6 +8,13 @@ export const SET_DYNAMIC_BRANDING_DATA = 'SET_DYNAMIC_BRANDING_DATA';*/export const SET_DYNAMIC_BRANDING_FAILED = 'SET_DYNAMIC_BRANDING_FAILED';+/**+ * Action used to set the branded icons once their SVG contents have been loaded.+ * They are delivered separately from {@code SET_DYNAMIC_BRANDING_DATA} so the rest of+ * the branding (theme, logo, backgrounds) is applied without waiting for the icons.+ */+export const SET_DYNAMIC_BRANDING_ICONS = 'SET_DYNAMIC_BRANDING_ICONS';+/*** Action used to signal the branding elements are ready to be displayed*/diff --git a/react/features/dynamic-branding/actions.any.ts b/react/features/dynamic-branding/actions.any.tsindex 79fedcd208..fa8df3ce2b 100644--- a/react/features/dynamic-branding/actions.any.ts+++ b/react/features/dynamic-branding/actions.any.ts@@ -4,6 +4,7 @@ import { doGetJSON } from '../base/util/httpUtils';import {SET_DYNAMIC_BRANDING_DATA,SET_DYNAMIC_BRANDING_FAILED,+ SET_DYNAMIC_BRANDING_ICONS,SET_DYNAMIC_BRANDING_READY} from './actionTypes';import { getDynamicBrandingUrl } from './functions.any';@@ -55,6 +56,19 @@ export function setDynamicBrandingData(value: Object) {};}+/**+ * Action used to set the loaded branded icons.+ *+ * @param {Record<string, string>} icons - Map of icon name to sanitized SVG XML.+ * @returns {Object}+ */+export function setDynamicBrandingIcons(icons: Record<string, string>) {+ return {+ type: SET_DYNAMIC_BRANDING_ICONS,+ icons+ };+}+/*** Action used to signal the branding elements are ready to be displayed.*diff --git a/react/features/dynamic-branding/middleware.any.ts b/react/features/dynamic-branding/middleware.any.tsindex 02e14caa33..01020cc216 100644--- a/react/features/dynamic-branding/middleware.any.ts+++ b/react/features/dynamic-branding/middleware.any.ts@@ -7,27 +7,27 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';import { toState } from '../base/redux/functions';import { SET_DYNAMIC_BRANDING_DATA, SET_DYNAMIC_BRANDING_READY } from './actionTypes';+import { setDynamicBrandingIcons } from './actions.any';import { fetchCustomIcons } from './functions.any';import logger from './logger';MiddlewareRegistry.register(store => next => action => {switch (action.type) {case SET_DYNAMIC_BRANDING_DATA: {+ const result = next(action);const { customIcons } = action.value;+ // The icons are loaded separately so the theme and the rest of the branding are+ // applied right away instead of waiting for every SVG to arrive.if (customIcons) {fetchCustomIcons(customIcons)- .then(localCustomIcons => {- action.value.brandedIcons = localCustomIcons;-- return next(action);- })+ .then(icons => store.dispatch(setDynamicBrandingIcons(icons))).catch((error: any) => {logger.error('Error fetching branded custom icons:', error);});}- break;+ return result;}case PARTICIPANT_ROLE_CHANGED: {diff --git a/react/features/dynamic-branding/reducer.ts b/react/features/dynamic-branding/reducer.tsindex 655aeb7547..5e84c10423 100644--- a/react/features/dynamic-branding/reducer.ts+++ b/react/features/dynamic-branding/reducer.ts@@ -4,6 +4,7 @@ import { type Image } from '../virtual-background/constants';import {SET_DYNAMIC_BRANDING_DATA,SET_DYNAMIC_BRANDING_FAILED,+ SET_DYNAMIC_BRANDING_ICONS,SET_DYNAMIC_BRANDING_READY,UNSET_DYNAMIC_BRANDING} from './actionTypes';@@ -196,7 +197,6 @@ ReducerRegistry.register<IDynamicBrandingState>(STORE_NAME, (state = DEFAULT_STAavatarBackgrounds,backgroundColor,backgroundImageUrl,- brandedIcons,defaultBranding,didPageUrl,groupChatRequiresPermission,@@ -219,7 +219,6 @@ ReducerRegistry.register<IDynamicBrandingState>(STORE_NAME, (state = DEFAULT_STAavatarBackgrounds,backgroundColor,backgroundImageUrl,- brandedIcons,defaultBranding,didPageUrl,groupChatRequiresPermission,@@ -249,6 +248,12 @@ ReducerRegistry.register<IDynamicBrandingState>(STORE_NAME, (state = DEFAULT_STAuseDynamicBrandingData: true};}+ case SET_DYNAMIC_BRANDING_ICONS:+ return {+ ...state,+ brandedIcons: action.icons+ };+case SET_DYNAMIC_BRANDING_READY:return {...state,