aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modern/src/DevicesList.js5
-rw-r--r--modern/src/common/selectors.js7
-rw-r--r--modern/src/map/StatusView.js3
-rw-r--r--modern/src/settings/OptionsLayout/useRoutes.js5
4 files changed, 5 insertions, 15 deletions
diff --git a/modern/src/DevicesList.js b/modern/src/DevicesList.js
index a2495f9d..0ea07319 100644
--- a/modern/src/DevicesList.js
+++ b/modern/src/DevicesList.js
@@ -18,7 +18,6 @@ import { devicesActions } from './store';
import EditCollectionView from './EditCollectionView';
import { useEffectAsync } from './reactHelper';
import { formatPosition, getBatteryStatus, getStatusColor } from './common/formatter';
-import { getDevices, getPosition } from './common/selectors';
import { useTranslation } from './LocalizationProvider';
const useStyles = makeStyles((theme) => ({
@@ -66,7 +65,7 @@ const DeviceRow = ({ data, index, style }) => {
const { items } = data;
const item = items[index];
- const position = useSelector(getPosition(item.id));
+ const position = useSelector((state) => state.positions.items[item.id]);
const showIgnition = position?.attributes.hasOwnProperty('ignition') && position.attributes.ignition;
return (
@@ -109,7 +108,7 @@ const DeviceView = ({ updateTimestamp, onMenuClick, filter }) => {
const dispatch = useDispatch();
const listInnerEl = useRef(null);
- const items = useSelector(getDevices);
+ const items = useSelector((state) => Object.values(state.devices.items));
const [filteredItems, setFilteredItems] = useState(null);
useEffect(() => {
diff --git a/modern/src/common/selectors.js b/modern/src/common/selectors.js
deleted file mode 100644
index 0c4c02e1..00000000
--- a/modern/src/common/selectors.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export const getIsAdmin = (state) => state.session.user?.administrator;
-
-export const getUserId = (state) => state.session.user?.id;
-
-export const getDevices = (state) => Object.values(state.devices.items);
-
-export const getPosition = (id) => (state) => state.positions.items[id];
diff --git a/modern/src/map/StatusView.js b/modern/src/map/StatusView.js
index cec71f98..cdd6ecaf 100644
--- a/modern/src/map/StatusView.js
+++ b/modern/src/map/StatusView.js
@@ -18,7 +18,6 @@ import {
} from '../common/formatter';
import { useAttributePreference } from '../common/preferences';
import RemoveDialog from '../RemoveDialog';
-import { getPosition } from '../common/selectors';
import { useTranslation } from '../LocalizationProvider';
const useStyles = makeStyles((theme) => ({
@@ -41,7 +40,7 @@ const StatusView = ({
const [removeDialogShown, setRemoveDialogShown] = useState(false);
const device = useSelector((state) => state.devices.items[deviceId]);
- const position = useSelector(getPosition(deviceId));
+ const position = useSelector((state) => state.positions.items[deviceId]);
const distanceUnit = useAttributePreference('distanceUnit');
const speedUnit = useAttributePreference('speedUnit');
diff --git a/modern/src/settings/OptionsLayout/useRoutes.js b/modern/src/settings/OptionsLayout/useRoutes.js
index efbd9eb2..70662e4d 100644
--- a/modern/src/settings/OptionsLayout/useRoutes.js
+++ b/modern/src/settings/OptionsLayout/useRoutes.js
@@ -9,7 +9,6 @@ import BuildIcon from '@material-ui/icons/Build';
import PeopleIcon from '@material-ui/icons/People';
import BarChartIcon from '@material-ui/icons/BarChart';
import TodayIcon from '@material-ui/icons/Today';
-import { getIsAdmin, getUserId } from '../../common/selectors';
import { useTranslation } from '../../LocalizationProvider';
const useAdminRoutes = (t) => useMemo(() => [
@@ -84,8 +83,8 @@ const useMainRoutes = (t, userId) => useMemo(() => [
export default () => {
const t = useTranslation();
- const isAdmin = useSelector(getIsAdmin);
- const userId = useSelector(getUserId);
+ const isAdmin = useSelector((state) => state.session.user?.administrator);
+ const userId = useSelector((state) => state.session.user?.id);
const mainRoutes = useMainRoutes(t, userId);
const adminRoutes = useAdminRoutes(t);