From 79db6c8f3bc72b0d7978a693058127ef1113c332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 15 Mar 2022 17:36:48 +0100 Subject: [PATCH] Fixing a race condition in Jitsi When setting the name, in rare cases, Jitsi was not initialized yet and setting the name would cause a JS error. We are now waiting for Jitsi to be properly initialized before setting the name. --- front/src/WebRtc/JitsiFactory.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index d328a72d..3d58d9c2 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -197,7 +197,10 @@ class JitsiFactory { options.onload = () => doResolve(); //we want for the iframe to be loaded before triggering animations. this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options); - this.jitsiApi.executeCommand("displayName", playerName); + + this.jitsiApi.addListener("videoConferenceJoined", () => { + this.jitsiApi?.executeCommand("displayName", playerName); + }); this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback); this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);