aboutsummaryrefslogtreecommitdiff
path: root/modern/src/SocketController.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/SocketController.js')
-rw-r--r--modern/src/SocketController.js14
1 files changed, 3 insertions, 11 deletions
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js
index 87b842fa..970298c3 100644
--- a/modern/src/SocketController.js
+++ b/modern/src/SocketController.js
@@ -1,23 +1,21 @@
import React, { useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector, connect } from 'react-redux';
import { Snackbar } from '@mui/material';
-import { useNavigate } from 'react-router-dom';
import { positionsActions, devicesActions, sessionActions } from './store';
import { useEffectAsync } from './reactHelper';
import { useTranslation } from './common/components/LocalizationProvider';
import { snackBarDurationLongMs } from './common/util/duration';
-import usePersistedState from './common/util/usePersistedState';
import alarm from './resources/alarm.mp3';
import { eventsActions } from './store/events';
import useFeatures from './common/util/useFeatures';
+import { useAttributePreference } from './common/util/preferences';
const logoutCode = 4000;
const SocketController = () => {
const dispatch = useDispatch();
- const navigate = useNavigate();
const t = useTranslation();
const authenticated = useSelector((state) => !!state.session.user);
@@ -28,8 +26,8 @@ const SocketController = () => {
const [events, setEvents] = useState([]);
const [notifications, setNotifications] = useState([]);
- const [soundEvents] = usePersistedState('soundEvents', []);
- const [soundAlarms] = usePersistedState('soundAlarms', ['sos']);
+ const soundEvents = useAttributePreference('soundEvents', '');
+ const soundAlarms = useAttributePreference('soundAlarms', 'sos');
const features = useFeatures();
@@ -96,12 +94,6 @@ const SocketController = () => {
}
};
}
- const response = await fetch('/api/session');
- if (response.ok) {
- dispatch(sessionActions.updateUser(await response.json()));
- } else {
- navigate('/login');
- }
return null;
}, [authenticated]);