make sure the registed event for seachGames returns a Promise

This commit is contained in:
Zamitto 2024-04-28 00:13:29 -03:00
parent 013aa20745
commit 2a63d1f7ca
3 changed files with 13 additions and 10 deletions

View file

@ -1,11 +1,15 @@
import { registerEvent } from "../register-event"; import { registerEvent } from "../register-event";
import { searchGames } from "../helpers/search-games"; import { searchGames } from "../helpers/search-games";
import { CatalogueEntry } from "@types";
registerEvent( const searchGamesEvent = async (
(_event: Electron.IpcMainInvokeEvent, query: string) => _event: Electron.IpcMainInvokeEvent,
searchGames({ query, take: 12 }), query: string
{ ): Promise<CatalogueEntry[]> => {
return Promise.all(searchGames({ query, take: 12 }));
};
registerEvent(searchGamesEvent, {
name: "searchGames", name: "searchGames",
memoize: true, memoize: true,
} });
);

View file

@ -42,7 +42,6 @@ export interface SearchGamesArgs {
skip?: number; skip?: number;
} }
// Check if this function really needed to be an async function
export const searchGames = ({ export const searchGames = ({
query, query,
take, take,

View file

@ -25,7 +25,7 @@ export const requestSteam250 = async (path: string) => {
}) })
.filter((game) => game != null); .filter((game) => game != null);
}) })
.catch((_) => []); .catch((_) => [] as Steam250Game[]);
}; };
const steam250Paths = [ const steam250Paths = [