fix: changing get random game to work with shop block

This commit is contained in:
Hydra 2024-05-13 09:35:29 +01:00
parent 2475d48bc4
commit 5ab51e4547
No known key found for this signature in database
6 changed files with 58 additions and 42 deletions

View file

@ -1,9 +1,10 @@
import { shuffle } from "lodash-es";
import { Steam250Game, getSteam250List } from "@main/services";
import { getSteam250List } from "@main/services";
import { registerEvent } from "../register-event";
import { searchGames, searchRepacks } from "../helpers/search-games";
import type { Steam250Game } from "@types";
const state = { games: Array<Steam250Game>(), index: 0 };
@ -25,8 +26,6 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
return "";
}
const resultObjectId = state.games[state.index].objectID;
state.index += 1;
if (state.index == state.games.length) {
@ -34,7 +33,7 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
state.games = shuffle(state.games);
}
return resultObjectId;
return state.games[state.index];
};
registerEvent(getRandomGame, {

View file

@ -1,10 +1,7 @@
import axios from "axios";
import { JSDOM } from "jsdom";
export interface Steam250Game {
title: string;
objectID: string;
}
import type { Steam250Game } from "@types";
export const requestSteam250 = async (path: string) => {
return axios