mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
perf: improving get-random-game performance
This commit is contained in:
parent
467ea29ec2
commit
c6242fa3e1
2 changed files with 5 additions and 8 deletions
|
@ -5,8 +5,6 @@ import { getSteam250List } from "@main/services";
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { searchSteamGames } from "../helpers/search-games";
|
import { searchSteamGames } from "../helpers/search-games";
|
||||||
import type { Steam250Game } from "@types";
|
import type { Steam250Game } from "@types";
|
||||||
import { repacksWorker } from "@main/workers";
|
|
||||||
import { formatName } from "@shared";
|
|
||||||
|
|
||||||
const state = { games: Array<Steam250Game>(), index: 0 };
|
const state = { games: Array<Steam250Game>(), index: 0 };
|
||||||
|
|
||||||
|
@ -17,12 +15,9 @@ const filterGames = async (games: Steam250Game[]) => {
|
||||||
const catalogue = await searchSteamGames({ query: game.title });
|
const catalogue = await searchSteamGames({ query: game.title });
|
||||||
|
|
||||||
if (catalogue.length) {
|
if (catalogue.length) {
|
||||||
const repacks = await repacksWorker.run(
|
const [steamGame] = catalogue;
|
||||||
{ query: formatName(catalogue[0].title) },
|
|
||||||
{ name: "search" }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (repacks.length) {
|
if (steamGame.repacks.length) {
|
||||||
results.push(game);
|
results.push(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@ export const setRepacks = (repacks: GameRepack[]) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const search = (options: flexSearch.SearchOptions) =>
|
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;
|
export const list = () => state.repacks;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue