Update Players and Games on connection check

This commit is contained in:
2025-05-27 02:29:46 +02:00
parent 1df2506b8c
commit 327885f968

View File

@ -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(() => {