From fb74d21d4bc8e088399d11a870f38a4ebcce1978 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Mon, 26 Jun 2023 20:11:40 +0200 Subject: [PATCH] delay connectBroadcast in order to ensure subject --- ccp/js/executionhistorycontroller.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ccp/js/executionhistorycontroller.js b/ccp/js/executionhistorycontroller.js index 7c253ae..330a3c1 100644 --- a/ccp/js/executionhistorycontroller.js +++ b/ccp/js/executionhistorycontroller.js @@ -29,7 +29,7 @@ class CCPExecutionHistory extends HTMLElement { } connectedCallback(){ - this.connectBroadcast() + this.connectBroadcastWithSubject() this.render() this.refreshExecutions() } @@ -272,6 +272,15 @@ class CCPExecutionHistory extends HTMLElement { }) } + connectBroadcastWithSubject(){ + var interval = window.setInterval( ()=>{ + if(this.#boot.subject){ + window.clearInterval(interval) + this.connectBroadcast() + } + }, 1000) + } + connectBroadcast(){ this.#socket = new WebSocket(`${this.#broadcasturl}/unified?subject=${this.#boot.subject}`); this.#socket.onmessage = event=>{