From eea701f046c8f32f399badacea5712c66e77e229 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Thu, 25 Sep 2025 15:44:11 +0300 Subject: [PATCH] Fix: updated pinnedDate logic, set default values for pagination, deleted comments, deleted example in user-profile-context --- src/main/events/library/add-game-to-pinned.ts | 4 ++-- src/main/events/user/get-user-library.ts | 13 ++++--------- .../context/user-profile/user-profile.context.tsx | 3 +-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/events/library/add-game-to-pinned.ts b/src/main/events/library/add-game-to-pinned.ts index 95ea0b82..82b62d7b 100644 --- a/src/main/events/library/add-game-to-pinned.ts +++ b/src/main/events/library/add-game-to-pinned.ts @@ -13,13 +13,13 @@ const addGameToPinned = async ( const game = await gamesSublevel.get(gameKey); if (!game) return; - HydraApi.put(`/profile/games/${shop}/${objectId}/pin`).catch(() => {}); + const response = await HydraApi.put(`/profile/games/${shop}/${objectId}/pin`); try { await gamesSublevel.put(gameKey, { ...game, pinned: true, - pinnedDate: new Date(), + pinnedDate: new Date(response.pinnedDate), }); } catch (error) { throw new Error(`Failed to update game pinned status: ${error}`); diff --git a/src/main/events/user/get-user-library.ts b/src/main/events/user/get-user-library.ts index 00922b9a..8a715a49 100644 --- a/src/main/events/user/get-user-library.ts +++ b/src/main/events/user/get-user-library.ts @@ -5,18 +5,13 @@ import type { UserLibraryResponse } from "@types"; const getUserLibrary = async ( _event: Electron.IpcMainInvokeEvent, userId: string, - take?: number, - skip?: number + take: number = 12, + skip: number = 0 ): Promise => { const params = new URLSearchParams(); - if (take !== undefined) { - params.append("take", take.toString()); - } - - if (skip !== undefined) { - params.append("skip", skip.toString()); - } + params.append("take", take.toString()); + params.append("skip", skip.toString()); const queryString = params.toString(); const baseUrl = `/users/${userId}/library`; diff --git a/src/renderer/src/context/user-profile/user-profile.context.tsx b/src/renderer/src/context/user-profile/user-profile.context.tsx index e7cbdfd9..22f7e16b 100644 --- a/src/renderer/src/context/user-profile/user-profile.context.tsx +++ b/src/renderer/src/context/user-profile/user-profile.context.tsx @@ -93,8 +93,7 @@ export function UserProfileContextProvider({ const getUserLibraryGames = useCallback(async () => { try { - // Example usage with pagination: take=24, skip=0 - const response = await window.electron.getUserLibrary(userId, 24, 0); + const response = await window.electron.getUserLibrary(userId); if (response) { setLibraryGames(response.library); setPinnedGames(response.pinnedGames);