From 1ddbbd3563af77a218020021ea50a8832900b4db Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 22 Aug 2017 17:08:55 +0200 Subject: Add route logic for construction routes --- src/api/sagas/objects.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/api/sagas/objects.js') diff --git a/src/api/sagas/objects.js b/src/api/sagas/objects.js index fd7830b3..98c766ec 100644 --- a/src/api/sagas/objects.js +++ b/src/api/sagas/objects.js @@ -1,5 +1,5 @@ import {call, put, select} from "redux-saga/effects"; -import {addToSimulationStore, addToUserStore} from "../../actions/objects"; +import {addToStore} from "../../actions/objects"; import {getSimulation} from "../routes/simulations"; import {getUser} from "../routes/users"; @@ -9,16 +9,16 @@ const selectors = { authorization: state => state.objects.authorization, }; -function* fetchAndStoreObject(objectType, id, apiCall, addToStore) { +function* fetchAndStoreObject(objectType, id, apiCall) { const objectStore = yield select(selectors[objectType]); if (!objectStore[id]) { const object = yield apiCall; - yield put(addToStore(object)); + yield put(addToStore(objectType, object)); } } export const fetchAndStoreSimulation = (id) => - fetchAndStoreObject("simulation", id, call(getSimulation, id), addToSimulationStore); + fetchAndStoreObject("simulation", id, call(getSimulation, id)); export const fetchAndStoreUser = (id) => - fetchAndStoreObject("user", id, call(getUser, id), addToUserStore); + fetchAndStoreObject("user", id, call(getUser, id),); -- cgit v1.2.3