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

only open websockets of ICs with configured input or output signals #278

This commit is contained in:
Laura Fuentes Grau 2021-04-06 18:40:16 +02:00
parent 726f6767d7
commit 715ca76bae

View file

@ -177,11 +177,22 @@ 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 (this.state.ics !== undefined && !Dashboard.webSocketsOpened) {
if (this.state.ics.length > 0) {
console.log("Starting to open IC websockets:", this.state.ics);
// only open sockets of ICs with configured input or output signals
let relevantICs = this.state.ics.filter(ic => {
let result = false;
this.state.configs.forEach(config => {
if(ic.id === config.icID && (config.inputLength !== 0 || config.outputLength !== 0)){
result = true;
}
})
return result;
})
if (relevantICs.length > 0) {
console.log("Starting to open IC websockets:", relevantICs);
AppDispatcher.dispatch({
type: 'ics/open-sockets',
data: this.state.ics
data: relevantICs
});
Dashboard.webSocketsOpened = true;