diff --git a/src/main/events/user/get-user-library.ts b/src/main/events/user/get-user-library.ts index b7d6a86d..a8cca461 100644 --- a/src/main/events/user/get-user-library.ts +++ b/src/main/events/user/get-user-library.ts @@ -9,19 +9,19 @@ const getUserLibrary = async ( skip?: number ): Promise => { const params = new URLSearchParams(); - + if (take !== undefined) { - params.append('take', take.toString()); + params.append("take", take.toString()); } - + if (skip !== undefined) { - params.append('skip', skip.toString()); + params.append("skip", skip.toString()); } - + const queryString = params.toString(); - const url = `/users/${userId}/library${queryString ? `?${queryString}` : ''}`; - + const url = `/users/${userId}/library${queryString ? `?${queryString}` : ""}`; + return HydraApi.get(url).catch(() => null); }; -registerEvent("getUserLibrary", getUserLibrary); \ No newline at end of file +registerEvent("getUserLibrary", getUserLibrary); diff --git a/src/preload/index.ts b/src/preload/index.ts index 608d8dfb..b32fd6b0 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -370,7 +370,8 @@ contextBridge.exposeInMainWorld("electron", { /* User */ getUser: (userId: string) => ipcRenderer.invoke("getUser", userId), - getUserLibrary: (userId: string, take?: number, skip?: number) => ipcRenderer.invoke("getUserLibrary", userId, take, skip), + getUserLibrary: (userId: string, take?: number, skip?: number) => + ipcRenderer.invoke("getUserLibrary", userId, take, skip), blockUser: (userId: string) => ipcRenderer.invoke("blockUser", userId), unblockUser: (userId: string) => ipcRenderer.invoke("unblockUser", userId), getUserFriends: (userId: string, take: number, skip: number) => diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index c81a7e86..115841d4 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -37,7 +37,6 @@ import type { ShopDetailsWithAssets, AchievementCustomNotificationPosition, AchievementNotificationInfo, - UserGame, UserLibraryResponse, } from "@types"; import type { AxiosProgressEvent } from "axios"; @@ -291,7 +290,11 @@ declare global { /* User */ getUser: (userId: string) => Promise; - getUserLibrary: (userId: string, take?: number, skip?: number) => Promise; + getUserLibrary: ( + userId: string, + take?: number, + skip?: number + ) => Promise; blockUser: (userId: string) => Promise; unblockUser: (userId: string) => Promise; getUserFriends: ( diff --git a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx index 134f1d49..db0891ac 100644 --- a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx +++ b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx @@ -9,7 +9,7 @@ import { PlusCircleIcon, } from "@primer/octicons-react"; import { Button } from "@renderer/components"; -import { useDownload, useLibrary, useToast } from "@renderer/hooks"; +import { useDownload, useLibrary, useToast, useUserDetails } from "@renderer/hooks"; import { useContext, useState } from "react"; import { useTranslation } from "react-i18next"; import { gameDetailsContext } from "@renderer/context"; @@ -21,6 +21,7 @@ export function HeroPanelActions() { useState(false); const { isGameDeleting } = useDownload(); + const { userDetails } = useUserDetails(); const { game, @@ -223,14 +224,16 @@ export function HeroPanelActions() { {game.favorite ? : } - + {userDetails && ( + + )}