summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 20:13:30 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-08 10:53:23 +0200
commit02a2f0f89cb1f39a5f8856bca1971a4e1b12374f (patch)
treedcea2fb2f46f47b0f5a961a52023510d227b5936 /opendc-web/opendc-web-ui/src/redux/sagas/topology.js
parent9c8a987556d0fb0cdf0eb67e0c191a8dcc5593b9 (diff)
ui: Use React Query defaults to reduce duplication
Diffstat (limited to 'opendc-web/opendc-web-ui/src/redux/sagas/topology.js')
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/topology.js28
1 files changed, 2 insertions, 26 deletions
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/topology.js b/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
index efa125c6..0ed40131 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
@@ -18,16 +18,12 @@ import {
} from '../../components/app/map/MapConstants'
import { fetchAndStoreTopology, denormalizeTopology, updateTopologyOnServer } from './objects'
import { uuid } from 'uuidv4'
-import { addTopology, deleteTopology } from '../../api/topologies'
-import { fetchProject } from '../../api/projects'
+import { addTopology } from '../../api/topologies'
export function* fetchAndStoreAllTopologiesOfProject(projectId, setTopology = false) {
try {
- const auth = yield getContext('auth')
const queryClient = yield getContext('queryClient')
- const project = yield call(() =>
- queryClient.fetchQuery(['projects', projectId], () => fetchProject(auth, projectId))
- )
+ const project = yield call(() => queryClient.fetchQuery(['projects', projectId]))
for (let i in project.topologyIds) {
yield fetchAndStoreTopology(project.topologyIds[i])
@@ -62,26 +58,6 @@ export function* onAddTopology(action) {
}
}
-export function* onDeleteTopology(action) {
- try {
- const auth = yield getContext('auth')
- const queryClient = yield getContext('queryClient')
- const project = yield call(() =>
- queryClient.fetchQuery(['projects', action.projectId], () => fetchProject(auth, action.projectId))
- )
- const topologyIds = project?.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, auth, action.id)
- } catch (error) {
- console.error(error)
- }
-}
-
export function* onStartNewRoomConstruction() {
try {
const topologyId = yield select((state) => state.currentTopologyId)