Merge branch 'main' of github.com:hydralauncher/hydra

This commit is contained in:
Chubby Granny Chaser 2024-09-13 00:04:07 +01:00
commit 8f0003298f
No known key found for this signature in database
23 changed files with 614 additions and 78 deletions

View file

@ -1,6 +1,3 @@
import { orderBy } from "lodash-es";
import flexSearch from "flexsearch";
import type { GameShop, CatalogueEntry, SteamGame } from "@types";
import { steamGamesWorker } from "@main/workers";
@ -23,20 +20,18 @@ export const convertSteamGameToCatalogueEntry = (
repacks: [],
});
export const searchSteamGames = async (
options: flexSearch.SearchOptions
): Promise<CatalogueEntry[]> => {
const steamGames = (await steamGamesWorker.run(options, {
name: "search",
})) as SteamGame[];
export const getSteamGameById = async (
objectId: string
): Promise<CatalogueEntry | null> => {
const steamGame = await steamGamesWorker.run(Number(objectId), {
name: "getById",
});
const result = RepacksManager.findRepacksForCatalogueEntries(
steamGames.map((game) => convertSteamGameToCatalogueEntry(game))
);
if (!steamGame) return null;
return orderBy(
result,
[({ repacks }) => repacks.length, "repacks"],
["desc"]
);
const catalogueEntry = convertSteamGameToCatalogueEntry(steamGame);
const result = RepacksManager.findRepacksForCatalogueEntry(catalogueEntry);
return result;
};