mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 11:42:21 +03:00
feat: refactor
This commit is contained in:
parent
2e82c29f4c
commit
b8c8e534b4
@ -1,7 +1,7 @@
|
|||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { getSteamGameById } from "../helpers/search-games";
|
import { convertSteamGameToCatalogueEntry } from "../helpers/search-games";
|
||||||
import { CatalogueEntry } from "@types";
|
import { CatalogueEntry } from "@types";
|
||||||
import { HydraApi } from "@main/services";
|
import { HydraApi, RepacksManager } from "@main/services";
|
||||||
|
|
||||||
const searchGamesEvent = async (
|
const searchGamesEvent = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
@ -11,14 +11,15 @@ const searchGamesEvent = async (
|
|||||||
{ objectId: string; title: string; shop: string }[]
|
{ objectId: string; title: string; shop: string }[]
|
||||||
>("/games/search", { title: query, take: 12, skip: 0 }, { needsAuth: false });
|
>("/games/search", { title: query, take: 12, skip: 0 }, { needsAuth: false });
|
||||||
|
|
||||||
const steamGames = await Promise.all(
|
const steamGames = games.map((game) => {
|
||||||
games.map((game) => getSteamGameById(game.objectId))
|
return convertSteamGameToCatalogueEntry({
|
||||||
);
|
id: Number(game.objectId),
|
||||||
const filteredGames = steamGames.filter(
|
name: game.title,
|
||||||
(game) => game !== null
|
clientIcon: null,
|
||||||
) as CatalogueEntry[];
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return filteredGames;
|
return RepacksManager.findRepacksForCatalogueEntries(steamGames);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("searchGames", searchGamesEvent);
|
registerEvent("searchGames", searchGamesEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user