1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Check if ICs are already loaded before attempting to open websockets

This commit is contained in:
Sonja Happ 2020-08-24 10:00:00 +02:00
parent 5d71bca954
commit 8a6de4b8cf

View file

@ -169,16 +169,19 @@ class Dashboard extends Component {
componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, 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