summaryrefslogtreecommitdiff
path: root/frontend/src/actions/simulation/tick.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-01 13:33:31 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:17 +0200
commitde8f12d74faef5fa3f9e38d1340948cab2d06ea3 (patch)
tree678bf1af3e5fa2334f0df43388d45294785bbf1e /frontend/src/actions/simulation/tick.js
parent44236756c4cf689806dc17c6950a2cff3e9227bf (diff)
Manually generate IDs
Diffstat (limited to 'frontend/src/actions/simulation/tick.js')
-rw-r--r--frontend/src/actions/simulation/tick.js76
1 files changed, 38 insertions, 38 deletions
diff --git a/frontend/src/actions/simulation/tick.js b/frontend/src/actions/simulation/tick.js
index a629b340..72387d24 100644
--- a/frontend/src/actions/simulation/tick.js
+++ b/frontend/src/actions/simulation/tick.js
@@ -1,49 +1,49 @@
-import { getDatacenterIdOfTick } from "../../util/timeline";
-import { setCurrentDatacenter } from "../topology/building";
+import { getDatacenterIdOfTick } from '../../util/timeline'
+import { setCurrentDatacenter } from '../topology/building'
-export const GO_TO_TICK = "GO_TO_TICK";
-export const SET_LAST_SIMULATED_TICK = "SET_LAST_SIMULATED_TICK";
+export const GO_TO_TICK = 'GO_TO_TICK'
+export const SET_LAST_SIMULATED_TICK = 'SET_LAST_SIMULATED_TICK'
export function incrementTick() {
- return (dispatch, getState) => {
- const { currentTick } = getState();
- dispatch(goToTick(currentTick + 1));
- };
+ return (dispatch, getState) => {
+ const { currentTick } = getState()
+ dispatch(goToTick(currentTick + 1))
+ }
}
export function goToTick(tick) {
- return (dispatch, getState) => {
- const state = getState();
-
- let sections = [];
- if (state.currentExperimentId !== -1) {
- const sectionIds =
- state.objects.path[
- state.objects.experiment[state.currentExperimentId].pathId
- ].sectionIds;
-
- if (sectionIds) {
- sections = sectionIds.map(
- sectionId => state.objects.section[sectionId]
- );
- }
- }
-
- const newDatacenterId = getDatacenterIdOfTick(tick, sections);
- if (state.currentDatacenterId !== newDatacenterId) {
- dispatch(setCurrentDatacenter(newDatacenterId));
+ return (dispatch, getState) => {
+ const state = getState()
+
+ let sections = []
+ if (state.currentExperimentId !== -1) {
+ const sectionIds =
+ state.objects.path[
+ state.objects.experiment[state.currentExperimentId].pathId
+ ].sectionIds
+
+ if (sectionIds) {
+ sections = sectionIds.map(
+ sectionId => state.objects.section[sectionId],
+ )
+ }
+ }
+
+ const newDatacenterId = getDatacenterIdOfTick(tick, sections)
+ if (state.currentDatacenterId !== newDatacenterId) {
+ dispatch(setCurrentDatacenter(newDatacenterId))
+ }
+
+ dispatch({
+ type: GO_TO_TICK,
+ tick,
+ })
}
-
- dispatch({
- type: GO_TO_TICK,
- tick
- });
- };
}
export function setLastSimulatedTick(tick) {
- return {
- type: SET_LAST_SIMULATED_TICK,
- tick
- };
+ return {
+ type: SET_LAST_SIMULATED_TICK,
+ tick,
+ }
}