From 327885f968b0964c97cc148a0706efab134646ec Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 May 2025 02:29:46 +0200 Subject: [PATCH] Update Players and Games on connection check --- src/App.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9b18edb..da2bf36 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -45,26 +45,19 @@ export default function App() { setOpenPlayerStats(true); } - useEffect(() => { - if(!connected) - { - setPlayers([]); - setGames([]); - return; - } - GetPlayers(apiUri).then(setPlayers); - GetGames(apiUri).then(setGames); - }, [connected]); - const checkConnection = () => { setCheckingConnection(true); return getData(`${apiUri}/swagger/v1/swagger.json`) .then(() => { setConnected(true); + GetPlayers(apiUri).then(setPlayers); + GetGames(apiUri).then(setGames); return Promise.resolve(); }) .catch(() => { setConnected(false) + setPlayers([]); + setGames([]); return Promise.reject(); }) .finally(() => {