Skip to content

Commit

Permalink
Revert "Added max device speed attribute"
Browse files Browse the repository at this point in the history
This reverts commit e9ac536.
  • Loading branch information
Kalabint committed Oct 1, 2024
1 parent e9ac536 commit 19d1bfb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
4 changes: 0 additions & 4 deletions src/common/attributes/useCommonUserAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,4 @@ export default (t) => useMemo(() => ({
name: t('attributeNavigationAppTitle'),
type: 'string',
},
'ui.MaxExpectedDeviceSpeed': {
name: t('attributeUIMaxExpectedDeviceSpeed'),
type: 'number',
},
}), [t]);
16 changes: 4 additions & 12 deletions src/map/MapRoutePath.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useTheme } from '@mui/styles';
import { useId, useEffect, useMemo } from 'react';
import { useId, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { map } from './core/MapView';
import getSpeedColor from '../common/util/colors';
import { useAttributePreference } from '../common/util/preferences';

const MapRoutePath = ({ positions }) => {
const id = useId();
const theme = useTheme();

const MaxExpectedDeviceSpeed = useAttributePreference('ui.MaxExpectedDeviceSpeed');
const theme = useTheme();

const reportColor = useSelector((state) => {
const position = positions?.find(() => true);
Expand All @@ -25,13 +23,6 @@ const MapRoutePath = ({ positions }) => {
return null;
});

const maxSpeed = useMemo(() => {
if (MaxExpectedDeviceSpeed > 0) {
return MaxExpectedDeviceSpeed;
}
return positions.map((item) => item.speed).reduce((a, b) => Math.max(a, b), -Infinity);
}, [MaxExpectedDeviceSpeed, positions]);

useEffect(() => {
map.addSource(id, {
type: 'geojson',
Expand Down Expand Up @@ -71,6 +62,7 @@ const MapRoutePath = ({ positions }) => {
}, []);

useEffect(() => {
const maxSpeed = positions.map((item) => item.speed).reduce((a, b) => Math.max(a, b), -Infinity);
const features = [];
for (let i = 0; i < positions.length - 1; i += 1) {
features.push({
Expand All @@ -91,7 +83,7 @@ const MapRoutePath = ({ positions }) => {
type: 'FeatureCollection',
features,
});
}, [theme, positions, reportColor, maxSpeed, id]);
}, [theme, positions, reportColor]);

return null;
};
Expand Down
16 changes: 3 additions & 13 deletions src/map/MapRoutePoints.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import {
useId, useCallback, useEffect, useMemo,
} from 'react';
import { useId, useCallback, useEffect } from 'react';
import { map } from './core/MapView';
import getSpeedColor from '../common/util/colors';
import { useAttributePreference } from '../common/util/preferences';

const MapRoutePoints = ({ positions, onClick }) => {
const id = useId();
const MaxExpectedDeviceSpeed = useAttributePreference('ui.MaxExpectedDeviceSpeed');

const onMouseEnter = () => map.getCanvas().style.cursor = 'pointer';
const onMouseLeave = () => map.getCanvas().style.cursor = '';
Expand All @@ -20,13 +16,6 @@ const MapRoutePoints = ({ positions, onClick }) => {
}
}, [onClick]);

const maxSpeed = useMemo(() => {
if (MaxExpectedDeviceSpeed > 0) {
return MaxExpectedDeviceSpeed;
}
return positions.map((p) => p.speed).reduce((a, b) => Math.max(a, b), -Infinity);
}, [MaxExpectedDeviceSpeed, positions]);

useEffect(() => {
map.addSource(id, {
type: 'geojson',
Expand Down Expand Up @@ -68,6 +57,7 @@ const MapRoutePoints = ({ positions, onClick }) => {
}, [onMarkerClick]);

useEffect(() => {
const maxSpeed = positions.map((p) => p.speed).reduce((a, b) => Math.max(a, b), -Infinity);
map.getSource(id)?.setData({
type: 'FeatureCollection',
features: positions.map((position, index) => ({
Expand All @@ -84,7 +74,7 @@ const MapRoutePoints = ({ positions, onClick }) => {
},
})),
});
}, [id, positions, maxSpeed]);
}, [onMarkerClick, positions]);

return null;
};
Expand Down
3 changes: 1 addition & 2 deletions src/resources/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,5 @@
"categoryVan": "Van",
"categoryScooter": "Scooter",
"maintenanceStart": "Start",
"maintenancePeriod": "Period",
"attributeUIMaxExpectedDeviceSpeed": "Max Expected Device Speed"
"maintenancePeriod": "Period"
}

0 comments on commit 19d1bfb

Please sign in to comment.