From f119fc78dda4d1e828dde04f378a63a93e3a0a7e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 2 Jul 2020 18:39:28 +0200 Subject: Add current progress on frontend port --- frontend/src/store/configure-store.js | 5 +---- frontend/src/store/middlewares/viewport-adjustment.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'frontend/src/store') diff --git a/frontend/src/store/configure-store.js b/frontend/src/store/configure-store.js index f01b61bb..d8f343ed 100644 --- a/frontend/src/store/configure-store.js +++ b/frontend/src/store/configure-store.js @@ -27,10 +27,7 @@ const middlewares = [ export let store = undefined export default function configureStore() { - const configuredStore = createStore( - rootReducer, - compose(persistState('auth'), applyMiddleware(...middlewares)), - ) + const configuredStore = createStore(rootReducer, compose(persistState('auth'), applyMiddleware(...middlewares))) sagaMiddleware.run(rootSaga) store = configuredStore diff --git a/frontend/src/store/middlewares/viewport-adjustment.js b/frontend/src/store/middlewares/viewport-adjustment.js index 0a074f61..ae8f032a 100644 --- a/frontend/src/store/middlewares/viewport-adjustment.js +++ b/frontend/src/store/middlewares/viewport-adjustment.js @@ -1,5 +1,5 @@ import { SET_MAP_DIMENSIONS, setMapPosition, setMapScale } from '../../actions/map' -import { SET_CURRENT_DATACENTER } from '../../actions/topology/building' +import { SET_CURRENT_TOPOLOGY } from '../../actions/topology/building' import { MAP_MAX_SCALE, MAP_MIN_SCALE, @@ -12,21 +12,21 @@ import { calculateRoomListBounds } from '../../util/tile-calculations' export const viewportAdjustmentMiddleware = store => next => action => { const state = store.getState() - let datacenterId = -1 + let topologyId = -1 let mapDimensions = {} - if (action.type === SET_CURRENT_DATACENTER && action.datacenterId !== -1) { - datacenterId = action.datacenterId + if (action.type === SET_CURRENT_TOPOLOGY && action.topologyId !== -1) { + topologyId = action.topologyId mapDimensions = state.map.dimensions } else if ( action.type === SET_MAP_DIMENSIONS && - state.currentDatacenterId !== -1 + state.currentTopologyId !== -1 ) { - datacenterId = state.currentDatacenterId + topologyId = state.currentTopologyId mapDimensions = { width: action.width, height: action.height } } - if (datacenterId !== -1) { - const roomIds = state.objects.datacenter[datacenterId].roomIds + if (topologyId !== -1) { + const roomIds = state.objects.topology[topologyId].roomIds const rooms = roomIds.map(id => Object.assign({}, state.objects.room[id])) rooms.forEach( room => -- cgit v1.2.3