mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Fix detection of simulator running state change
This commit is contained in:
parent
466bdf24cb
commit
3ed9c607c4
3 changed files with 18 additions and 6 deletions
|
@ -32,7 +32,7 @@ class App extends Component {
|
|||
static calculateState(prevState) {
|
||||
// get list of running simulators
|
||||
var simulators = SimulatorStore.getState().filter(simulator => {
|
||||
return simulator.running;
|
||||
return simulator.running === true;
|
||||
});
|
||||
|
||||
// check if running simulators changed
|
||||
|
@ -99,7 +99,7 @@ class App extends Component {
|
|||
const requiredSimulators = this.requiredSimulatorsBySimulations();
|
||||
|
||||
requiredSimulators.forEach(simulator => {
|
||||
this.connectSimulator(simulator);
|
||||
this.connectSimulator(nextState, simulator);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ class App extends Component {
|
|||
return simulators;
|
||||
}
|
||||
|
||||
connectSimulator(data) {
|
||||
connectSimulator(state, data) {
|
||||
// get simulator object
|
||||
const simulator = this.state.runningSimulators.find(element => {
|
||||
const simulator = state.runningSimulators.find(element => {
|
||||
return element._id === data.simulator;
|
||||
});
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ class SimulatorsDataManager extends RestDataManager {
|
|||
this._timers = [];
|
||||
}
|
||||
|
||||
startRunningDetection(simulator) {
|
||||
startRunningDetection(obj) {
|
||||
const simulator = JSON.parse(JSON.stringify(obj));
|
||||
|
||||
// check if timer is already running
|
||||
const index = this._timers.findIndex(timer => {
|
||||
return timer.simulator === simulator._id;
|
||||
|
|
|
@ -33,7 +33,17 @@ class SimulatorStore extends ArrayStore {
|
|||
return super.reduce(state, action);
|
||||
|
||||
case 'simulators/running':
|
||||
return this.updateElements(state, [ action.simulator ]);
|
||||
// check if simulator running state changed
|
||||
simulator = state.find(element => {
|
||||
return element._id === action.simulator._id;
|
||||
});
|
||||
|
||||
// only update if state changed
|
||||
if (simulator.running == null || simulator.running !== action.simulator.running) {
|
||||
state = this.updateElements(state, [ action.simulator ]);
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
case 'simulatorData/opened':
|
||||
// get simulator
|
||||
|
|
Loading…
Add table
Reference in a new issue