From 8a6de4b8cf082bc9db62bd92cecc8a8bee4681f9 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Mon, 24 Aug 2020 10:00:00 +0200 Subject: [PATCH] Check if ICs are already loaded before attempting to open websockets --- src/dashboard/dashboard.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index ff3c135..d0708d8 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -169,16 +169,19 @@ class Dashboard extends Component { componentDidUpdate(prevProps: Readonly

, prevState: Readonly, snapshot: SS) { // open web sockets if ICs are already known and sockets are not opened yet - if(!Dashboard.webSocketsOpened && this.state.ics.length > 0){ - console.log("Starting to open IC websockets:", this.state.ics); - AppDispatcher.dispatch({ - type: 'ics/open-sockets', - data: this.state.ics - }); + if(this.state.ics !== undefined && !Dashboard.webSocketsOpened){ + if(this.state.ics.length > 0){ + console.log("Starting to open IC websockets:", this.state.ics); + AppDispatcher.dispatch({ + type: 'ics/open-sockets', + data: this.state.ics + }); - Dashboard.webSocketsOpened = true; + Dashboard.webSocketsOpened = true; + } } + if(prevState.dashboard === undefined && this.state.dashboard !== undefined){ // the dashboard was loaded, so that the scenarioID is available