diff --git a/scripts/system/html/js/miniTablet.js b/scripts/system/html/js/miniTablet.js index c48201cef5..6bc75161b3 100644 --- a/scripts/system/html/js/miniTablet.js +++ b/scripts/system/html/js/miniTablet.js @@ -61,6 +61,11 @@ } switch (message.type) { + case READY_MESSAGE: + EventBridge.emitWebEvent(JSON.stringify({ + type: READY_MESSAGE + })); + break; case MUTE_MESSAGE: muteImage.src = message.icon; break; @@ -114,9 +119,6 @@ function connectEventBridge() { EventBridge.scriptEventReceived.connect(onScriptEventReceived); - EventBridge.emitWebEvent(JSON.stringify({ - type: READY_MESSAGE - })); } function disconnectEventBridge() { diff --git a/scripts/system/miniTablet.js b/scripts/system/miniTablet.js index 12550c9d9c..e99c2631d9 100644 --- a/scripts/system/miniTablet.js +++ b/scripts/system/miniTablet.js @@ -124,6 +124,7 @@ miniUIOverlayEnabled = false, MINI_UI_OVERLAY_ENABLED_DELAY = 500, miniOverlayObject = null, + isReady = false, // Button icons. MUTE_ON_ICON = Script.resourcesPath() + "icons/tablet-icons/mic-mute-a.svg", @@ -203,6 +204,7 @@ switch (message.type) { case READY_MESSAGE: // Send initial button statuses. + isReady = true; updateMutedStatus(); setGotoIcon(); break; @@ -979,13 +981,17 @@ } function updateState() { - if (!ui.miniOverlayObject) { - // Keep trying to connect the event bridge until we succeed - ui.miniOverlayObject = Overlays.getOverlayObject(ui.miniUIOverlay); - if (ui.miniOverlayObject) { - ui.miniOverlayObject.webEventReceived.connect(ui.onWebEventReceived); - ui.updateMutedStatus(); - ui.setGotoIcon(); + if (!ui.isReady) { + if (!ui.miniOverlayObject) { + // Keep trying to connect the event bridge until we succeed + ui.miniOverlayObject = Overlays.getOverlayObject(ui.miniUIOverlay); + if (ui.miniOverlayObject) { + ui.miniOverlayObject.webEventReceived.connect(ui.onWebEventReceived); + } + } else { + ui.miniOverlayObject.emitScriptEvent(JSON.stringify({ + type: READY_MESSAGE + })); } }