summaryrefslogtreecommitdiff
path: root/frontend/src/sagas
diff options
context:
space:
mode:
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, {