aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-06 15:07:13 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-06 15:07:13 -0700
commitcc03e41dd7f9f401797f39eb08e7d4617d624a2f (patch)
tree73e35b23c5d4d0f06382ec3ebd4c4da86611e65d /modern
parentd04cd5a9ca34f0528f3db6361641d20bc1a13320 (diff)
downloadetbsa-traccar-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.tar.gz
etbsa-traccar-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.tar.bz2
etbsa-traccar-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.zip
Fix duplicate loading
Diffstat (limited to 'modern')
-rw-r--r--modern/src/LoginPage.js2
-rw-r--r--modern/src/MainPage.js3
-rw-r--r--modern/src/MainToolbar.js1
-rw-r--r--modern/src/SocketController.js2
4 files changed, 4 insertions, 4 deletions
diff --git a/modern/src/LoginPage.js b/modern/src/LoginPage.js
index 1da3366..99ff95b 100644
--- a/modern/src/LoginPage.js
+++ b/modern/src/LoginPage.js
@@ -44,8 +44,6 @@ const useStyles = makeStyles(theme => ({
}));
const LoginPage = () => {
- const [filled, setFilled] = useState(false);
- const [loading, setLoading] = useState(false);
const [failed, setFailed] = useState(false);
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
diff --git a/modern/src/MainPage.js b/modern/src/MainPage.js
index c70e816..f81d5e7 100644
--- a/modern/src/MainPage.js
+++ b/modern/src/MainPage.js
@@ -40,13 +40,14 @@ const useStyles = makeStyles(theme => ({
}));
const MainPage = ({ width }) => {
- const [loading, setLoading] = useState(true);
+ const [loading, setLoading] = useState(!document.authenticated);
const classes = useStyles();
const history = useHistory();
useEffect(() => {
fetch('/api/session').then(response => {
if (response.ok) {
+ document.authenticated = true;
setLoading(false);
} else {
history.push('/login');
diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js
index bf4aa40..038ab30 100644
--- a/modern/src/MainToolbar.js
+++ b/modern/src/MainToolbar.js
@@ -46,6 +46,7 @@ const MainToolbar = () => {
const handleLogout = () => {
fetch('/api/session', { method: 'DELETE' }).then(response => {
if (response.ok) {
+ document.authenticated = false;
history.push('/login');
}
})
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js
index 6de3369..d693c43 100644
--- a/modern/src/SocketController.js
+++ b/modern/src/SocketController.js
@@ -54,7 +54,7 @@ const SocketController = (props) => {
}
connectSocket();
});
- }, []);
+ }, [dispatch, connectSocket]);
return null;
}