From 47bab68b52e36e29ec22a951665fbd11a9285cb7 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Tue, 17 Dec 2024 16:54:00 +0100 Subject: [PATCH] Don't call `login_info` twice on login/logout --- ui/src/components/App.jsx | 5 ++++- ui/src/requests.js | 13 ------------- 2 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 ui/src/requests.js diff --git a/ui/src/components/App.jsx b/ui/src/components/App.jsx index 1d75400b5..f42e5fb57 100644 --- a/ui/src/components/App.jsx +++ b/ui/src/components/App.jsx @@ -73,8 +73,11 @@ function App() { const loggedIn = useSelector((state) => state.login.loggedIn); useEffect(() => { + // Fetch login info on mount dispatch(getLoginInfo()).catch(showBoundary); // eslint-disable-line promise/prefer-await-to-then + }, [dispatch, showBoundary]); + useEffect(() => { if (loggedIn) { serverIO.listen(); const refreshInterval = setInterval(sendRefreshSession, REFRESH_INTERVAL); @@ -87,7 +90,7 @@ function App() { // no clean-up required, until we connect to serverIO return undefined; - }, [loggedIn, dispatch, showBoundary]); + }, [loggedIn]); if (loggedIn === null) { // Fetching login info diff --git a/ui/src/requests.js b/ui/src/requests.js deleted file mode 100644 index 770633093..000000000 --- a/ui/src/requests.js +++ /dev/null @@ -1,13 +0,0 @@ -export function checkStatus(response) { - if (response.status < 200 || response.status >= 300) { - const error = new Error(response.statusText); - error.response = response; - throw error; - } - - return response; -} - -export function parseJSON(response) { - return response.json(); -}