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 { searchGames } from "../helpers/search-games";
import { CatalogueEntry } from "@types";
registerEvent(
(_event: Electron.IpcMainInvokeEvent, query: string) =>
searchGames({ query, take: 12 }),
{
name: "searchGames",
memoize: true,
}
);
const searchGamesEvent = async (
_event: Electron.IpcMainInvokeEvent,
query: string
): Promise<CatalogueEntry[]> => {
return Promise.all(searchGames({ query, take: 12 }));
};
registerEvent(searchGamesEvent, {
name: "searchGames",
memoize: true,
});

View file

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

View file

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