mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 03:32:13 +00:00
feat: adjustments
This commit is contained in:
parent
523d711b49
commit
330dd9c218
2 changed files with 10 additions and 10 deletions
|
@ -6,7 +6,7 @@ import { registerEvent } from "../register-event";
|
|||
import { searchGames, searchRepacks } from "../helpers/search-games";
|
||||
import { formatName } from "@main/helpers";
|
||||
|
||||
let gamesList = new Array<Steam250Game>();
|
||||
let gamesList: Steam250Game[] = [];
|
||||
let nextGameIndex = 0;
|
||||
|
||||
const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
|
@ -24,15 +24,15 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||
const repacks = searchRepacks(formatName(game.title));
|
||||
|
||||
if (repacks.length) {
|
||||
const results = await searchGames({ query: game.title });
|
||||
const catalogueResults = await searchGames({ query: game.title });
|
||||
|
||||
if (results.length) {
|
||||
resultObjectId = results[0].objectID;
|
||||
if (catalogueResults.length) {
|
||||
resultObjectId = catalogueResults[0].objectID;
|
||||
}
|
||||
}
|
||||
nextGameIndex += 1;
|
||||
|
||||
if (nextGameIndex == gamesList.length - 1) {
|
||||
if (nextGameIndex == gamesList.length) {
|
||||
nextGameIndex = 0;
|
||||
gamesList = shuffle(gamesList);
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ export const requestSteam250 = async (path: string) => {
|
|||
const { window } = new JSDOM(response.data);
|
||||
const { document } = window;
|
||||
|
||||
return Array.from(document.querySelectorAll(".appline .title a")).map(
|
||||
($title: HTMLAnchorElement) => {
|
||||
return Array.from(document.querySelectorAll(".appline .title a"))
|
||||
.map(($title: HTMLAnchorElement) => {
|
||||
const steamGameUrl = $title.href;
|
||||
if (!steamGameUrl) return null;
|
||||
|
||||
return {
|
||||
title: $title.textContent,
|
||||
objectID: steamGameUrl.split("/").pop(),
|
||||
};
|
||||
}
|
||||
);
|
||||
} as Steam250Game;
|
||||
})
|
||||
.filter((game) => game != null);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue