feat: simplify get user event

This commit is contained in:
Zamitto
2025-05-09 18:50:14 -03:00
parent 382a618c3f
commit 64cea7ff85

View File

@@ -6,22 +6,7 @@ const getUser = async (
_event: Electron.IpcMainInvokeEvent,
userId: string
): Promise<UserProfile | null> => {
try {
const profile = await HydraApi.get<UserProfile | null>(`/users/${userId}`);
if (!profile) return null;
const recentGames = profile.recentGames.filter((game) => game);
const libraryGames = profile.libraryGames.filter((game) => game);
return {
...profile,
libraryGames,
recentGames,
};
} catch (err) {
return null;
}
return HydraApi.get<UserProfile>(`/users/${userId}`).catch(() => null);
};
registerEvent("getUser", getUser);