diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-06 15:07:13 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-06 15:07:13 -0700 |
commit | cc03e41dd7f9f401797f39eb08e7d4617d624a2f (patch) | |
tree | 73e35b23c5d4d0f06382ec3ebd4c4da86611e65d | |
parent | d04cd5a9ca34f0528f3db6361641d20bc1a13320 (diff) | |
download | trackermap-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.tar.gz trackermap-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.tar.bz2 trackermap-web-cc03e41dd7f9f401797f39eb08e7d4617d624a2f.zip |
Fix duplicate loading
-rw-r--r-- | modern/src/LoginPage.js | 2 | ||||
-rw-r--r-- | modern/src/MainPage.js | 3 | ||||
-rw-r--r-- | modern/src/MainToolbar.js | 1 | ||||
-rw-r--r-- | modern/src/SocketController.js | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/modern/src/LoginPage.js b/modern/src/LoginPage.js index 1da33663..99ff95b6 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 c70e8169..f81d5e74 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 bf4aa402..038ab30a 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 6de3369a..d693c43d 100644 --- a/modern/src/SocketController.js +++ b/modern/src/SocketController.js @@ -54,7 +54,7 @@ const SocketController = (props) => { } connectSocket(); }); - }, []); + }, [dispatch, connectSocket]); return null; } |