diff options
Diffstat (limited to 'src/reducers')
| -rw-r--r-- | src/reducers/construction.js | 36 | ||||
| -rw-r--r-- | src/reducers/index.js | 5 | ||||
| -rw-r--r-- | src/reducers/topology.js | 19 |
3 files changed, 40 insertions, 20 deletions
diff --git a/src/reducers/construction.js b/src/reducers/construction.js new file mode 100644 index 00000000..33485842 --- /dev/null +++ b/src/reducers/construction.js @@ -0,0 +1,36 @@ +import {combineReducers} from "redux"; +import { + CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED, + FINISH_NEW_ROOM_CONSTRUCTION, + START_NEW_ROOM_CONSTRUCTION_SUCCEEDED, + START_OBJECT_CONSTRUCTION, + STOP_OBJECT_CONSTRUCTION +} from "../actions/topology"; + +export function currentRoomInConstruction(state = -1, action) { + switch (action.type) { + case START_NEW_ROOM_CONSTRUCTION_SUCCEEDED: + return action.roomId; + case CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED: + case FINISH_NEW_ROOM_CONSTRUCTION: + return -1; + default: + return state; + } +} + +export function inObjectConstructionMode(state = false, action) { + switch (action.type) { + case START_OBJECT_CONSTRUCTION: + return true; + case STOP_OBJECT_CONSTRUCTION: + return false; + default: + return state; + } +} + +export const construction = combineReducers({ + currentRoomInConstruction, + inObjectConstructionMode, +}); diff --git a/src/reducers/index.js b/src/reducers/index.js index d3ace393..2dc6b8af 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,10 +1,11 @@ import {combineReducers} from "redux"; import {auth} from "./auth"; +import {construction} from "./construction"; import {interactionLevel} from "./interaction-level"; import {modals} from "./modals"; import {objects} from "./objects"; import {authorizationsOfCurrentUser, authVisibilityFilter, currentSimulationId} from "./simulations"; -import {currentDatacenterId, currentRoomInConstruction} from "./topology"; +import {currentDatacenterId} from "./topology"; const rootReducer = combineReducers({ auth, @@ -15,7 +16,7 @@ const rootReducer = combineReducers({ currentSimulationId, currentDatacenterId, interactionLevel, - currentRoomInConstruction, + construction, }); export default rootReducer; diff --git a/src/reducers/topology.js b/src/reducers/topology.js index c8690816..caafb7c1 100644 --- a/src/reducers/topology.js +++ b/src/reducers/topology.js @@ -1,9 +1,4 @@ -import { - CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED, - FETCH_LATEST_DATACENTER_SUCCEEDED, - FINISH_NEW_ROOM_CONSTRUCTION, - START_NEW_ROOM_CONSTRUCTION_SUCCEEDED -} from "../actions/topology"; +import {FETCH_LATEST_DATACENTER_SUCCEEDED} from "../actions/topology"; export function currentDatacenterId(state = -1, action) { switch (action.type) { @@ -13,15 +8,3 @@ export function currentDatacenterId(state = -1, action) { return state; } } - -export function currentRoomInConstruction(state = -1, action) { - switch (action.type) { - case START_NEW_ROOM_CONSTRUCTION_SUCCEEDED: - return action.roomId; - case CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED: - case FINISH_NEW_ROOM_CONSTRUCTION: - return -1; - default: - return state; - } -} |
