mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-25 20:01:03 +00:00
fix possibility of 404 on home if getRandomGame has no validy elements to return
this can happen when user has no internet connection when opening hydra
This commit is contained in:
@@ -7,7 +7,9 @@ export interface Steam250Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const requestSteam250 = async (path: string) => {
|
export const requestSteam250 = async (path: string) => {
|
||||||
return axios.get(`https://steam250.com${path}`).then((response) => {
|
return axios
|
||||||
|
.get(`https://steam250.com${path}`)
|
||||||
|
.then((response) => {
|
||||||
const { window } = new JSDOM(response.data);
|
const { window } = new JSDOM(response.data);
|
||||||
const { document } = window;
|
const { document } = window;
|
||||||
|
|
||||||
@@ -22,7 +24,8 @@ export const requestSteam250 = async (path: string) => {
|
|||||||
} as Steam250Game;
|
} as Steam250Game;
|
||||||
})
|
})
|
||||||
.filter((game) => game != null);
|
.filter((game) => game != null);
|
||||||
});
|
})
|
||||||
|
.catch((_) => []);
|
||||||
};
|
};
|
||||||
|
|
||||||
const steam250Paths = [
|
const steam250Paths = [
|
||||||
|
|||||||
@@ -58,13 +58,11 @@ export function Home() {
|
|||||||
const getRandomGame = useCallback(() => {
|
const getRandomGame = useCallback(() => {
|
||||||
setIsLoadingRandomGame(true);
|
setIsLoadingRandomGame(true);
|
||||||
|
|
||||||
window.electron
|
window.electron.getRandomGame().then((objectID) => {
|
||||||
.getRandomGame()
|
if (objectID) {
|
||||||
.then((objectID) => {
|
|
||||||
randomGameObjectID.current = objectID;
|
randomGameObjectID.current = objectID;
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setIsLoadingRandomGame(false);
|
setIsLoadingRandomGame(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user