From b8c8e534b4631f1a3724b3ba84b7b650ae194e28 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:35:14 -0300 Subject: [PATCH] feat: refactor --- src/main/events/catalogue/search-games.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/events/catalogue/search-games.ts b/src/main/events/catalogue/search-games.ts index 504b0209..ebe601f2 100644 --- a/src/main/events/catalogue/search-games.ts +++ b/src/main/events/catalogue/search-games.ts @@ -1,7 +1,7 @@ import { registerEvent } from "../register-event"; -import { getSteamGameById } from "../helpers/search-games"; +import { convertSteamGameToCatalogueEntry } from "../helpers/search-games"; import { CatalogueEntry } from "@types"; -import { HydraApi } from "@main/services"; +import { HydraApi, RepacksManager } from "@main/services"; const searchGamesEvent = async ( _event: Electron.IpcMainInvokeEvent, @@ -11,14 +11,15 @@ const searchGamesEvent = async ( { objectId: string; title: string; shop: string }[] >("/games/search", { title: query, take: 12, skip: 0 }, { needsAuth: false }); - const steamGames = await Promise.all( - games.map((game) => getSteamGameById(game.objectId)) - ); - const filteredGames = steamGames.filter( - (game) => game !== null - ) as CatalogueEntry[]; + const steamGames = games.map((game) => { + return convertSteamGameToCatalogueEntry({ + id: Number(game.objectId), + name: game.title, + clientIcon: null, + }); + }); - return filteredGames; + return RepacksManager.findRepacksForCatalogueEntries(steamGames); }; registerEvent("searchGames", searchGamesEvent);