aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-26 16:33:23 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-26 16:33:23 -0700
commit6226b06271ae75e0be28dd16c64cf2e3c7392718 (patch)
treefc57b02c7827e95015d7f66c639f104cb3ba45f0 /modern
parent3a651e5f02a90857e4023edb7ac9785d569417dd (diff)
downloadtrackermap-web-6226b06271ae75e0be28dd16c64cf2e3c7392718.tar.gz
trackermap-web-6226b06271ae75e0be28dd16c64cf2e3c7392718.tar.bz2
trackermap-web-6226b06271ae75e0be28dd16c64cf2e3c7392718.zip
Simplify map plugins
Diffstat (limited to 'modern')
-rw-r--r--modern/src/main/MainPage.js11
-rw-r--r--modern/src/map/main/MapCurrentPositions.js18
2 files changed, 8 insertions, 21 deletions
diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js
index 29aaf1aa..6102a005 100644
--- a/modern/src/main/MainPage.js
+++ b/modern/src/main/MainPage.js
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Paper, Toolbar, TextField, IconButton, Button,
@@ -19,7 +19,6 @@ import Map from '../map/core/Map';
import MapSelectedDevice from '../map/main/MapSelectedDevice';
import MapAccuracy from '../map/main/MapAccuracy';
import MapGeofence from '../map/main/MapGeofence';
-import MapCurrentPositions from '../map/main/MapCurrentPositions';
import MapCurrentLocation from '../map/MapCurrentLocation';
import BottomMenu from '../common/components/BottomMenu';
import { useTranslation } from '../common/components/LocalizationProvider';
@@ -31,6 +30,7 @@ import MapDefaultCamera from '../map/main/MapDefaultCamera';
import usePersistedState from '../common/util/usePersistedState';
import MapLiveRoutes from '../map/main/MapLiveRoutes';
import { useDeviceReadonly } from '../common/util/permissions';
+import MapPositions from '../map/MapPositions';
const useStyles = makeStyles((theme) => ({
root: {
@@ -132,6 +132,7 @@ const MainPage = () => {
const [mapLiveRoutes] = usePersistedState('mapLiveRoutes', false);
const selectedDeviceId = useSelector((state) => state.devices.selectedId);
+ const positions = useSelector((state) => Object.values(state.positions.items));
const [searchKeyword, setSearchKeyword] = useState('');
const [collapsed, setCollapsed] = useState(false);
@@ -142,13 +143,17 @@ const MainPage = () => {
useEffect(() => setCollapsed(!desktop), [desktop]);
+ const onClick = useCallback((_, deviceId) => {
+ dispatch(devicesActions.select(deviceId));
+ }, [dispatch]);
+
return (
<div className={classes.root}>
<Map>
<MapGeofence />
<MapAccuracy />
{mapLiveRoutes && <MapLiveRoutes />}
- <MapCurrentPositions />
+ <MapPositions positions={positions} onClick={onClick} />
<MapDefaultCamera />
<MapSelectedDevice />
<PoiMap />
diff --git a/modern/src/map/main/MapCurrentPositions.js b/modern/src/map/main/MapCurrentPositions.js
deleted file mode 100644
index ff05d2d1..00000000
--- a/modern/src/map/main/MapCurrentPositions.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React, { useCallback } from 'react';
-import { useDispatch, useSelector } from 'react-redux';
-
-import { devicesActions } from '../../store';
-import MapPositions from '../MapPositions';
-
-const MapCurrentPositions = () => {
- const dispatch = useDispatch();
-
- const onClick = useCallback((_, deviceId) => {
- dispatch(devicesActions.select(deviceId));
- }, [dispatch]);
-
- const positions = useSelector((state) => state.positions.items);
- return (<MapPositions positions={Object.values(positions)} onClick={onClick} />);
-};
-
-export default MapCurrentPositions;