aboutsummaryrefslogtreecommitdiff
path: root/modern/src/MainMap.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-25 00:31:37 -0700
committerGitHub <noreply@github.com>2020-03-25 00:31:37 -0700
commitb10607f96ad72f5f971fbd867eeeeb86380f79cb (patch)
tree81b7a13c0c3fc4da12182ee20518f021406def9b /modern/src/MainMap.js
parent78d69f50595e058a08f3eaaa47fd7c3745fa1266 (diff)
parent37f8b1cd81614ed9281647b326a30d58123c5942 (diff)
downloadtrackermap-web-b10607f96ad72f5f971fbd867eeeeb86380f79cb.tar.gz
trackermap-web-b10607f96ad72f5f971fbd867eeeeb86380f79cb.tar.bz2
trackermap-web-b10607f96ad72f5f971fbd867eeeeb86380f79cb.zip
Merge pull request #772 from dt-ap/experiment/redux-toolkit
Experimental: Use Redux Toolkit
Diffstat (limited to 'modern/src/MainMap.js')
-rw-r--r--modern/src/MainMap.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js
index 35b933b4..01230da9 100644
--- a/modern/src/MainMap.js
+++ b/modern/src/MainMap.js
@@ -4,8 +4,8 @@ import { connect } from 'react-redux';
import mapboxgl from 'mapbox-gl';
const calculateMapCenter = (state) => {
- if (state.selectedDevice) {
- const position = state.positions.get(state.selectedDevice);
+ if (state.devices.selectedId) {
+ const position = state.positions.items[state.devices.selectedId] || null;
if (position) {
return [position.longitude, position.latitude];
}
@@ -14,8 +14,9 @@ const calculateMapCenter = (state) => {
}
const mapFeatureProperties = (state, position) => {
+ const device = state.devices.items[position.deviceId] || null;
return {
- name: state.devices.get(position.deviceId).name
+ name: device ? device.name : ''
}
}
@@ -23,7 +24,7 @@ const mapStateToProps = state => ({
mapCenter: calculateMapCenter(state),
data: {
type: 'FeatureCollection',
- features: Array.from(state.positions.values()).map(position => ({
+ features: Object.values(state.positions.items).map(position => ({
type: 'Feature',
geometry: {
type: 'Point',