summaryrefslogtreecommitdiff
path: root/frontend/src/sagas
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-03 10:34:05 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:22 +0200
commit39277c91281dbc7bd40bdffabc5b5675e9ede483 (patch)
tree24a8bc60bef68f911748e1ca635e525b9888a298 /frontend/src/sagas
parent107a48e1a7fa0ec56faad8d8e90f76521f39f3b2 (diff)
Get basic topology change working
Diffstat (limited to 'frontend/src/sagas')
-rw-r--r--frontend/src/sagas/topology.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/frontend/src/sagas/topology.js b/frontend/src/sagas/topology.js
index e7ce9043..f86dcdc3 100644
--- a/frontend/src/sagas/topology.js
+++ b/frontend/src/sagas/topology.js
@@ -50,11 +50,10 @@ export function* onAddTopology(action) {
const topology = yield call(
addTopology,
Object.assign({}, action.topology, {
- _id: -1,
simulationId: currentSimulationId,
})
)
- yield put(addToStore('topology', topology))
+ yield fetchAndStoreTopology(topology._id)
const topologyIds = yield select((state) => state.objects.simulation[currentSimulationId].topologyIds)
yield put(
@@ -62,6 +61,7 @@ export function* onAddTopology(action) {
topologyIds: topologyIds.concat([topology._id]),
})
)
+ yield put(setCurrentTopology(topology._id))
} catch (error) {
console.error(error)
}
@@ -69,10 +69,14 @@ export function* onAddTopology(action) {
export function* onDeleteTopology(action) {
try {
- yield call(deleteTopology, action.id)
-
const currentSimulationId = yield select((state) => state.currentSimulationId)
const topologyIds = yield select((state) => state.objects.simulation[currentSimulationId].topologyIds)
+ const currentTopologyId = yield select((state) => state.currentTopologyId)
+ if (currentTopologyId === action.id) {
+ yield put(setCurrentTopology(topologyIds.filter(t => t !== action.id)[0]))
+ }
+
+ yield call(deleteTopology, action.id)
yield put(
addPropToStoreObject('simulation', currentSimulationId, {