aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;