diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index cec70774..28c27046 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -7,22 +7,25 @@ export interface Steam250Game { } export const requestSteam250 = async (path: string) => { - return axios.get(`https://steam250.com${path}`).then((response) => { - const { window } = new JSDOM(response.data); - const { document } = window; + return axios + .get(`https://steam250.com${path}`) + .then((response) => { + const { window } = new JSDOM(response.data); + const { document } = window; - return Array.from(document.querySelectorAll(".appline .title a")) - .map(($title: HTMLAnchorElement) => { - const steamGameUrl = $title.href; - if (!steamGameUrl) return null; + return Array.from(document.querySelectorAll(".appline .title a")) + .map(($title: HTMLAnchorElement) => { + const steamGameUrl = $title.href; + if (!steamGameUrl) return null; - return { - title: $title.textContent, - objectID: steamGameUrl.split("/").pop(), - } as Steam250Game; - }) - .filter((game) => game != null); - }); + return { + title: $title.textContent, + objectID: steamGameUrl.split("/").pop(), + } as Steam250Game; + }) + .filter((game) => game != null); + }) + .catch((_) => []); }; const steam250Paths = [ diff --git a/src/renderer/pages/home/home.tsx b/src/renderer/pages/home/home.tsx index ed650245..33811483 100644 --- a/src/renderer/pages/home/home.tsx +++ b/src/renderer/pages/home/home.tsx @@ -58,14 +58,12 @@ export function Home() { const getRandomGame = useCallback(() => { setIsLoadingRandomGame(true); - window.electron - .getRandomGame() - .then((objectID) => { + window.electron.getRandomGame().then((objectID) => { + if (objectID) { randomGameObjectID.current = objectID; - }) - .finally(() => { setIsLoadingRandomGame(false); - }); + } + }); }, []); const handleRandomizerClick = () => {