From 8eece72a81fc6efe012ec526dbf12c2696bfc887 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Sat, 27 Apr 2024 22:04:35 -0300 Subject: [PATCH] removing async from searchGames --- src/main/events/helpers/search-games.ts | 15 +++++++-------- src/main/services/steam-250.ts | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/events/helpers/search-games.ts b/src/main/events/helpers/search-games.ts index 5fb3cea0..6d6f1ded 100644 --- a/src/main/events/helpers/search-games.ts +++ b/src/main/events/helpers/search-games.ts @@ -42,11 +42,12 @@ export interface SearchGamesArgs { skip?: number; } -export const searchGames = async ({ +// Check if this function really needed to be an async function +export const searchGames = ({ query, take, skip, -}: SearchGamesArgs): Promise => { +}: SearchGamesArgs): CatalogueEntry[] => { const results = steamGamesIndex .search(formatName(query || ""), { limit: take, offset: skip }) .map((index) => { @@ -61,11 +62,9 @@ export const searchGames = async ({ }; }); - return Promise.all(results).then((resultsWithRepacks) => - orderBy( - resultsWithRepacks, - [({ repacks }) => repacks.length, "repacks"], - ["desc"] - ) + return orderBy( + results, + [({ repacks }) => repacks.length, "repacks"], + ["desc"] ); }; diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts index 28c27046..f0aee3bf 100644 --- a/src/main/services/steam-250.ts +++ b/src/main/services/steam-250.ts @@ -39,10 +39,10 @@ export const getSteam250List = async () => { const gamesPromises = steam250Paths.map((path) => requestSteam250(path)); const gamesList = (await Promise.all(gamesPromises)).flat(); - const gamesMap = gamesList.reduce((map, item) => { + const gamesMap: Map = gamesList.reduce((map, item) => { map.set(item.objectID, item); return map; - }, new Map()); + }, new Map()); return [...gamesMap.values()]; };