mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
perf: improving get-random-game performance
This commit is contained in:
@@ -5,8 +5,6 @@ import { getSteam250List } from "@main/services";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { searchSteamGames } from "../helpers/search-games";
|
||||
import type { Steam250Game } from "@types";
|
||||
import { repacksWorker } from "@main/workers";
|
||||
import { formatName } from "@shared";
|
||||
|
||||
const state = { games: Array<Steam250Game>(), index: 0 };
|
||||
|
||||
@@ -17,12 +15,9 @@ const filterGames = async (games: Steam250Game[]) => {
|
||||
const catalogue = await searchSteamGames({ query: game.title });
|
||||
|
||||
if (catalogue.length) {
|
||||
const repacks = await repacksWorker.run(
|
||||
{ query: formatName(catalogue[0].title) },
|
||||
{ name: "search" }
|
||||
);
|
||||
const [steamGame] = catalogue;
|
||||
|
||||
if (repacks.length) {
|
||||
if (steamGame.repacks.length) {
|
||||
results.push(game);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ export const setRepacks = (repacks: GameRepack[]) => {
|
||||
};
|
||||
|
||||
export const search = (options: flexSearch.SearchOptions) =>
|
||||
repacksIndex.search(options).map((index) => state.repacks[index]);
|
||||
repacksIndex
|
||||
.search({ ...options, query: formatName(options.query ?? "") })
|
||||
.map((index) => state.repacks[index]);
|
||||
|
||||
export const list = () => state.repacks;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user