From dacaf347fd0b4a87cf031e1167466368311af5ef Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 18:40:05 -0300 Subject: [PATCH 01/13] feat: get all games on first request --- src/main/events/catalogue/get-random-game.ts | 39 ++++++++++++++------ src/main/services/steam-250.ts | 13 +++++-- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index 07a827dd..d4bfd6af 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -1,27 +1,44 @@ import shuffle from "lodash/shuffle"; -import { getRandomSteam250List } from "@main/services"; +import { Steam250Game, getSteam250List } from "@main/services"; import { registerEvent } from "../register-event"; import { searchGames, searchRepacks } from "../helpers/search-games"; import { formatName } from "@main/helpers"; +let gamesList = new Array(); +let nextGameIndex = 0; + const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { - return getRandomSteam250List().then(async (games) => { - const shuffledList = shuffle(games); + if (gamesList.length == 0) { + console.log("fetching steam 250 pages"); + gamesList = shuffle(await getSteam250List()); + } else { + console.log("getting cached list"); + } - for (const game of shuffledList) { - const repacks = searchRepacks(formatName(game.title)); + let resultObjectId = ""; - if (repacks.length) { - const results = await searchGames({ query: game.title }); + while (!resultObjectId) { + const game = gamesList[nextGameIndex]; + const repacks = searchRepacks(formatName(game.title)); - if (results.length) { - return results[0].objectID; - } + if (repacks.length) { + const results = await searchGames({ query: game.title }); + + if (results.length) { + resultObjectId = results[0].objectID; } } - }); + nextGameIndex += 1; + + if (nextGameIndex == gamesList.length - 1) { + nextGameIndex = 0; + gamesList = shuffle(gamesList); + } + } + + return resultObjectId; }; registerEvent(getRandomGame, { diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index 6447c226..079f067f 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -1,6 +1,10 @@ import axios from "axios"; import { JSDOM } from "jsdom"; -import shuffle from "lodash/shuffle"; + +export interface Steam250Game { + title: string; + objectID: string; +} export const requestSteam250 = async (path: string) => { return axios.get(`https://steam250.com${path}`).then((response) => { @@ -28,7 +32,8 @@ const steam250Paths = [ "/most_played", ]; -export const getRandomSteam250List = async () => { - const [path] = shuffle(steam250Paths); - return requestSteam250(path); +export const getSteam250List = async () => { + const gamesPromises = steam250Paths.map((path) => requestSteam250(path)); + const gamesList = (await Promise.all(gamesPromises)).flat(); + return [...new Set(gamesList)]; }; From b6c54c103d2b793d5415e89b9c9bc8d017d7f10f Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 18:41:37 -0300 Subject: [PATCH 02/13] feat: game-details call getRandomCall on button click --- .../pages/game-details/game-details.tsx | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/renderer/pages/game-details/game-details.tsx b/src/renderer/pages/game-details/game-details.tsx index 7f744198..9015823f 100644 --- a/src/renderer/pages/game-details/game-details.tsx +++ b/src/renderer/pages/game-details/game-details.tsx @@ -53,18 +53,10 @@ export function GameDetails() { const [showRepacksModal, setShowRepacksModal] = useState(false); const [showSelectFolderModal, setShowSelectFolderModal] = useState(false); - const randomGameObjectID = useRef(null); - const dispatch = useAppDispatch(); const { game: gameDownloading, startDownload, isDownloading } = useDownload(); - const getRandomGame = useCallback(() => { - window.electron.getRandomGame().then((objectID) => { - randomGameObjectID.current = objectID; - }); - }, []); - const handleImageSettled = useCallback((url: string) => { average(url, { amount: 1, format: "hex" }) .then((color) => { @@ -89,8 +81,6 @@ export function GameDetails() { setIsGamePlaying(false); dispatch(setHeaderTitle("")); - getRandomGame(); - window.electron .getGameShopDetails(objectID, "steam", getSteamLanguage(i18n.language)) .then((result) => { @@ -114,7 +104,7 @@ export function GameDetails() { getGame(); setHowLongToBeat({ isLoading: true, data: null }); - }, [getGame, getRandomGame, dispatch, navigate, objectID, i18n.language]); + }, [getGame, dispatch, navigate, objectID, i18n.language]); const isGameDownloading = isDownloading && gameDownloading?.id === game?.id; @@ -158,16 +148,14 @@ export function GameDetails() { }); }; - const handleRandomizerClick = () => { - if (!randomGameObjectID.current) return; + const handleRandomizerClick = async () => { + const randomGameObjectID = await window.electron.getRandomGame(); const searchParams = new URLSearchParams({ fromRandomizer: "1", }); - navigate( - `/game/steam/${randomGameObjectID.current}?${searchParams.toString()}` - ); + navigate(`/game/steam/${randomGameObjectID}?${searchParams.toString()}`); }; const fromRandomizer = searchParams.get("fromRandomizer"); From 1b2d857dd106f6626b6ebe316e103a0304abb263 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 19:54:37 -0300 Subject: [PATCH 03/13] feat: adjustments --- src/main/events/catalogue/get-random-game.ts | 10 +++++----- src/main/services/steam-250.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index d4bfd6af..c7484d6b 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -6,7 +6,7 @@ import { registerEvent } from "../register-event"; import { searchGames, searchRepacks } from "../helpers/search-games"; import { formatName } from "@main/helpers"; -let gamesList = new Array(); +let gamesList: Steam250Game[] = []; let nextGameIndex = 0; const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { @@ -24,15 +24,15 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { const repacks = searchRepacks(formatName(game.title)); if (repacks.length) { - const results = await searchGames({ query: game.title }); + const catalogueResults = await searchGames({ query: game.title }); - if (results.length) { - resultObjectId = results[0].objectID; + if (catalogueResults.length) { + resultObjectId = catalogueResults[0].objectID; } } nextGameIndex += 1; - if (nextGameIndex == gamesList.length - 1) { + if (nextGameIndex == gamesList.length) { nextGameIndex = 0; gamesList = shuffle(gamesList); } diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index 079f067f..dc84cb21 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -11,17 +11,17 @@ export const requestSteam250 = async (path: string) => { const { window } = new JSDOM(response.data); const { document } = window; - return Array.from(document.querySelectorAll(".appline .title a")).map( - ($title: HTMLAnchorElement) => { + 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); }); }; From 5ede782acd3e42f9a5f16e812637bb2c628e726d Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 20:15:24 -0300 Subject: [PATCH 04/13] fix: possible bug when catalogue returns games with similar name --- src/main/events/catalogue/get-random-game.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index c7484d6b..fc7cb5db 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -27,7 +27,7 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { const catalogueResults = await searchGames({ query: game.title }); if (catalogueResults.length) { - resultObjectId = catalogueResults[0].objectID; + resultObjectId = game.objectID; } } nextGameIndex += 1; From 913699e4b6c6e358e4a818d8ff804a76f6e8b9d3 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 20:42:28 -0300 Subject: [PATCH 05/13] replace Set with Map --- src/main/services/steam-250.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index dc84cb21..cec70774 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -35,5 +35,11 @@ const steam250Paths = [ export const getSteam250List = async () => { const gamesPromises = steam250Paths.map((path) => requestSteam250(path)); const gamesList = (await Promise.all(gamesPromises)).flat(); - return [...new Set(gamesList)]; + + const gamesMap = gamesList.reduce((map, item) => { + map.set(item.objectID, item); + return map; + }, new Map()); + + return [...gamesMap.values()]; }; From 0b8ebcbfd88a402c4ac66f6d54fde3f77e6bc86f Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 20:42:50 -0300 Subject: [PATCH 06/13] renaming variables --- src/main/events/catalogue/get-random-game.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index fc7cb5db..d3f82590 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -20,14 +20,13 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { let resultObjectId = ""; while (!resultObjectId) { - const game = gamesList[nextGameIndex]; - const repacks = searchRepacks(formatName(game.title)); + const nextGame = gamesList[nextGameIndex]; + const repacks = searchRepacks(formatName(nextGame.title)); if (repacks.length) { - const catalogueResults = await searchGames({ query: game.title }); - + const catalogueResults = await searchGames({ query: nextGame.title }); if (catalogueResults.length) { - resultObjectId = game.objectID; + resultObjectId = nextGame.objectID; } } nextGameIndex += 1; From 15edc1698af3f51d2d5d9adeda1df9f96f84e424 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 20:43:34 -0300 Subject: [PATCH 07/13] 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 --- src/main/services/steam-250.ts | 31 +++++++++++++++++-------------- src/renderer/pages/home/home.tsx | 10 ++++------ 2 files changed, 21 insertions(+), 20 deletions(-) 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 = () => { From a89686a45b7cd2f963be853260bceeb5b43e5961 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 21:00:57 -0300 Subject: [PATCH 08/13] feat: disable next random suggestion button until game details finish loading --- src/renderer/pages/game-details/game-details.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/renderer/pages/game-details/game-details.tsx b/src/renderer/pages/game-details/game-details.tsx index 9015823f..2dc44418 100644 --- a/src/renderer/pages/game-details/game-details.tsx +++ b/src/renderer/pages/game-details/game-details.tsx @@ -33,6 +33,7 @@ export function GameDetails() { const { objectID, shop } = useParams(); const [isLoading, setIsLoading] = useState(false); + const [isLoadingRandomGame, setIsLoadingRandomGame] = useState(false); const [color, setColor] = useState(""); const [gameDetails, setGameDetails] = useState(null); const [howLongToBeat, setHowLongToBeat] = useState<{ @@ -97,6 +98,7 @@ export function GameDetails() { setGameDetails(result); dispatch(setHeaderTitle(result.name)); + setIsLoadingRandomGame(false); }) .finally(() => { setIsLoading(false); @@ -149,6 +151,7 @@ export function GameDetails() { }; const handleRandomizerClick = async () => { + setIsLoadingRandomGame(true); const randomGameObjectID = await window.electron.getRandomGame(); const searchParams = new URLSearchParams({ @@ -269,6 +272,7 @@ export function GameDetails() { className={styles.randomizerButton} onClick={handleRandomizerClick} theme="outline" + disabled={isLoadingRandomGame} >
Date: Sat, 27 Apr 2024 22:04:35 -0300 Subject: [PATCH 09/13] removing async from searchGames --- src/main/events/helpers/search-games.ts | 15 +++++++-------- src/main/services/steam-250.ts | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/events/helpers/search-games.ts b/src/main/events/helpers/search-games.ts index 5fb3cea0..6d6f1ded 100644 --- a/src/main/events/helpers/search-games.ts +++ b/src/main/events/helpers/search-games.ts @@ -42,11 +42,12 @@ export interface SearchGamesArgs { skip?: number; } -export const searchGames = async ({ +// Check if this function really needed to be an async function +export const searchGames = ({ query, take, skip, -}: SearchGamesArgs): Promise => { +}: SearchGamesArgs): CatalogueEntry[] => { const results = steamGamesIndex .search(formatName(query || ""), { limit: take, offset: skip }) .map((index) => { @@ -61,11 +62,9 @@ export const searchGames = async ({ }; }); - return Promise.all(results).then((resultsWithRepacks) => - orderBy( - resultsWithRepacks, - [({ repacks }) => repacks.length, "repacks"], - ["desc"] - ) + return orderBy( + results, + [({ repacks }) => repacks.length, "repacks"], + ["desc"] ); }; diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index 28c27046..f0aee3bf 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -39,10 +39,10 @@ export const getSteam250List = async () => { const gamesPromises = steam250Paths.map((path) => requestSteam250(path)); const gamesList = (await Promise.all(gamesPromises)).flat(); - const gamesMap = gamesList.reduce((map, item) => { + const gamesMap: Map = gamesList.reduce((map, item) => { map.set(item.objectID, item); return map; - }, new Map()); + }, new Map()); return [...gamesMap.values()]; }; From 0759813ed58f6fa365f7925a660011b78d1b4a67 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 22:04:42 -0300 Subject: [PATCH 10/13] refactor get-random-game --- src/main/events/catalogue/get-random-game.ts | 38 ++++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index d3f82590..82a7966b 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -4,37 +4,35 @@ import { Steam250Game, getSteam250List } from "@main/services"; import { registerEvent } from "../register-event"; import { searchGames, searchRepacks } from "../helpers/search-games"; -import { formatName } from "@main/helpers"; let gamesList: Steam250Game[] = []; let nextGameIndex = 0; const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { if (gamesList.length == 0) { - console.log("fetching steam 250 pages"); - gamesList = shuffle(await getSteam250List()); - } else { - console.log("getting cached list"); + const steam250List = await getSteam250List(); + + const filteredSteam250List = steam250List.filter((game) => { + const repacks = searchRepacks(game.title); + const catalogue = searchGames({ query: game.title }); + + return repacks.length && catalogue.length; + }); + + gamesList = shuffle(filteredSteam250List); } - let resultObjectId = ""; + if (gamesList.length == 0) { + return ""; + } - while (!resultObjectId) { - const nextGame = gamesList[nextGameIndex]; - const repacks = searchRepacks(formatName(nextGame.title)); + const resultObjectId = gamesList[nextGameIndex].objectID; - if (repacks.length) { - const catalogueResults = await searchGames({ query: nextGame.title }); - if (catalogueResults.length) { - resultObjectId = nextGame.objectID; - } - } - nextGameIndex += 1; + nextGameIndex += 1; - if (nextGameIndex == gamesList.length) { - nextGameIndex = 0; - gamesList = shuffle(gamesList); - } + if (nextGameIndex == gamesList.length) { + nextGameIndex = 0; + gamesList = shuffle(gamesList); } return resultObjectId; From 8c9ab2012bcdafe13238fc964000cbcfa5c0d589 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sun, 28 Apr 2024 00:13:29 -0300 Subject: [PATCH 11/13] make sure the registed event for seachGames returns a Promise --- src/main/events/catalogue/search-games.ts | 20 ++++++++++++-------- src/main/events/helpers/search-games.ts | 1 - src/main/services/steam-250.ts | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/events/catalogue/search-games.ts b/src/main/events/catalogue/search-games.ts index eb9c0640..cdb84d56 100644 --- a/src/main/events/catalogue/search-games.ts +++ b/src/main/events/catalogue/search-games.ts @@ -1,11 +1,15 @@ import { registerEvent } from "../register-event"; import { searchGames } from "../helpers/search-games"; +import { CatalogueEntry } from "@types"; -registerEvent( - (_event: Electron.IpcMainInvokeEvent, query: string) => - searchGames({ query, take: 12 }), - { - name: "searchGames", - memoize: true, - } -); +const searchGamesEvent = async ( + _event: Electron.IpcMainInvokeEvent, + query: string +): Promise => { + return Promise.all(searchGames({ query, take: 12 })); +}; + +registerEvent(searchGamesEvent, { + name: "searchGames", + memoize: true, +}); diff --git a/src/main/events/helpers/search-games.ts b/src/main/events/helpers/search-games.ts index 6d6f1ded..50777dd7 100644 --- a/src/main/events/helpers/search-games.ts +++ b/src/main/events/helpers/search-games.ts @@ -42,7 +42,6 @@ export interface SearchGamesArgs { skip?: number; } -// Check if this function really needed to be an async function export const searchGames = ({ query, take, diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index f0aee3bf..f5c92364 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -25,7 +25,7 @@ export const requestSteam250 = async (path: string) => { }) .filter((game) => game != null); }) - .catch((_) => []); + .catch((_) => [] as Steam250Game[]); }; const steam250Paths = [ From f14148861a79f5d2649a68f471d13e3f07c840fe Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sun, 28 Apr 2024 00:28:12 -0300 Subject: [PATCH 12/13] remove unused import and fix lint --- src/renderer/pages/game-details/game-details.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/game-details/game-details.tsx b/src/renderer/pages/game-details/game-details.tsx index 2dc44418..41ba215e 100644 --- a/src/renderer/pages/game-details/game-details.tsx +++ b/src/renderer/pages/game-details/game-details.tsx @@ -1,6 +1,6 @@ import Color from "color"; import { average } from "color.js"; -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { useNavigate, useParams, useSearchParams } from "react-router-dom"; import type { From eb8dc38f1e81b8c39dbfe8e5e043be0f0daa92a7 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Mon, 29 Apr 2024 14:12:06 -0300 Subject: [PATCH 13/13] changes after pr review --- src/main/events/catalogue/get-random-game.ts | 19 +++++++++---------- src/main/events/catalogue/search-games.ts | 2 +- src/main/services/steam-250.ts | 5 +++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/events/catalogue/get-random-game.ts b/src/main/events/catalogue/get-random-game.ts index 82a7966b..d0d013e7 100644 --- a/src/main/events/catalogue/get-random-game.ts +++ b/src/main/events/catalogue/get-random-game.ts @@ -5,11 +5,10 @@ import { Steam250Game, getSteam250List } from "@main/services"; import { registerEvent } from "../register-event"; import { searchGames, searchRepacks } from "../helpers/search-games"; -let gamesList: Steam250Game[] = []; -let nextGameIndex = 0; +const state = { games: Array(), index: 0 }; const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { - if (gamesList.length == 0) { + if (state.games.length == 0) { const steam250List = await getSteam250List(); const filteredSteam250List = steam250List.filter((game) => { @@ -19,20 +18,20 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => { return repacks.length && catalogue.length; }); - gamesList = shuffle(filteredSteam250List); + state.games = shuffle(filteredSteam250List); } - if (gamesList.length == 0) { + if (state.games.length == 0) { return ""; } - const resultObjectId = gamesList[nextGameIndex].objectID; + const resultObjectId = state.games[state.index].objectID; - nextGameIndex += 1; + state.index += 1; - if (nextGameIndex == gamesList.length) { - nextGameIndex = 0; - gamesList = shuffle(gamesList); + if (state.index == state.games.length) { + state.index = 0; + state.games = shuffle(state.games); } return resultObjectId; diff --git a/src/main/events/catalogue/search-games.ts b/src/main/events/catalogue/search-games.ts index cdb84d56..f0539562 100644 --- a/src/main/events/catalogue/search-games.ts +++ b/src/main/events/catalogue/search-games.ts @@ -6,7 +6,7 @@ const searchGamesEvent = async ( _event: Electron.IpcMainInvokeEvent, query: string ): Promise => { - return Promise.all(searchGames({ query, take: 12 })); + return searchGames({ query, take: 12 }); }; registerEvent(searchGamesEvent, { diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index f5c92364..89836d89 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -36,8 +36,9 @@ const steam250Paths = [ ]; export const getSteam250List = async () => { - const gamesPromises = steam250Paths.map((path) => requestSteam250(path)); - const gamesList = (await Promise.all(gamesPromises)).flat(); + const gamesList = ( + await Promise.all(steam250Paths.map((path) => requestSteam250(path))) + ).flat(); const gamesMap: Map = gamesList.reduce((map, item) => { map.set(item.objectID, item);