From e8b1b286a3ddb80dfd5620f368dcf1583b093f43 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 17 Feb 2021 18:49:55 +0100 Subject: [PATCH] Merge Jitsi config --- front/src/WebRtc/JitsiFactory.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index 41a5c388..860c2919 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -1,9 +1,16 @@ import {JITSI_URL} from "../Enum/EnvironmentVariable"; import {mediaManager} from "./MediaManager"; import {coWebsiteManager} from "./CoWebsiteManager"; +import {AddPlayerInterface} from "../Phaser/Game/AddPlayerInterface"; declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any -const getDefaultConfig = () => { +interface jitsiConfigInterface { + startWithAudioMuted: boolean + startWithVideoMuted: boolean + prejoinPageEnabled: boolean +} + +const getDefaultConfig = () : jitsiConfigInterface => { return { startWithAudioMuted: !mediaManager.constraintsMedia.audio, startWithVideoMuted: mediaManager.constraintsMedia.video === false, @@ -11,6 +18,18 @@ const getDefaultConfig = () => { } } +const mergeConfig = (config?: object) => { + const currentDefaultConfig = getDefaultConfig(); + if(!config){ + return currentDefaultConfig; + } + return { + startWithAudioMuted: (config as jitsiConfigInterface).startWithAudioMuted ? true : currentDefaultConfig.startWithAudioMuted, + startWithVideoMuted: (config as jitsiConfigInterface).startWithVideoMuted ? true : currentDefaultConfig.startWithVideoMuted, + prejoinPageEnabled: (config as jitsiConfigInterface).prejoinPageEnabled ? true : currentDefaultConfig.prejoinPageEnabled + } +} + const defaultInterfaceConfig = { SHOW_CHROME_EXTENSION_BANNER: false, MOBILE_APP_PROMO: false, @@ -76,7 +95,7 @@ class JitsiFactory { width: "100%", height: "100%", parentNode: cowebsiteDiv, - configOverwrite: {...config, ...getDefaultConfig()}, + configOverwrite: mergeConfig(config), interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig} }; if (!options.jwt) {