diff options
Diffstat (limited to 'frontend/src/containers/app/map/layers/RoomHoverLayer.js')
| -rw-r--r-- | frontend/src/containers/app/map/layers/RoomHoverLayer.js | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/frontend/src/containers/app/map/layers/RoomHoverLayer.js b/frontend/src/containers/app/map/layers/RoomHoverLayer.js index 2c886c2f..66404f9e 100644 --- a/frontend/src/containers/app/map/layers/RoomHoverLayer.js +++ b/frontend/src/containers/app/map/layers/RoomHoverLayer.js @@ -7,49 +7,40 @@ import { findPositionInRooms, } from '../../../../util/tile-calculations' -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { mapPosition: state.map.position, mapScale: state.map.scale, isEnabled: () => state.construction.currentRoomInConstruction !== '-1', isValid: (x, y) => { - const newRoom = Object.assign( - {}, - state.objects.room[state.construction.currentRoomInConstruction], - ) + const newRoom = Object.assign({}, state.objects.room[state.construction.currentRoomInConstruction]) const oldRooms = Object.keys(state.objects.room) - .map(id => Object.assign({}, state.objects.room[id])) + .map((id) => Object.assign({}, state.objects.room[id])) .filter( - room => - state.objects.topology[state.currentTopologyId].roomIds.indexOf( - room._id, - ) !== -1 && room._id !== state.construction.currentRoomInConstruction, - ); + (room) => + state.objects.topology[state.currentTopologyId].roomIds.indexOf(room._id) !== -1 && + room._id !== state.construction.currentRoomInConstruction + ) - [...oldRooms, newRoom].forEach(room => { - room.tiles = room.tileIds.map(tileId => state.objects.tile[tileId]) + ;[...oldRooms, newRoom].forEach((room) => { + room.tiles = room.tileIds.map((tileId) => state.objects.tile[tileId]) }) if (newRoom.tileIds.length === 0) { return findPositionInRooms(oldRooms, x, y) === -1 } - const validNextPositions = deriveValidNextTilePositions( - oldRooms, - newRoom.tiles, - ) + const validNextPositions = deriveValidNextTilePositions(oldRooms, newRoom.tiles) return findPositionInPositions(validNextPositions, x, y) !== -1 }, } } -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch) => { return { onClick: (x, y) => dispatch(toggleTileAtLocation(x, y)), } } -const RoomHoverLayer = connect(mapStateToProps, mapDispatchToProps)( - RoomHoverLayerComponent, -) +const RoomHoverLayer = connect(mapStateToProps, mapDispatchToProps)(RoomHoverLayerComponent) export default RoomHoverLayer |
