From d2b3508b5b55c8dbf1067e33f4ec26f4a85f33bb Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 26 May 2025 11:47:36 -0300 Subject: [PATCH] fix: refactor and fix types --- src/main/events/library/sync-game-by-object-id.ts | 8 ++++++-- src/types/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/events/library/sync-game-by-object-id.ts b/src/main/events/library/sync-game-by-object-id.ts index 6aa1c77b..0630ceb9 100644 --- a/src/main/events/library/sync-game-by-object-id.ts +++ b/src/main/events/library/sync-game-by-object-id.ts @@ -14,9 +14,13 @@ const syncGameByObjectId = async ( const gameKey = levelKeys.game(shop, objectId); const game = await gamesSublevel.get(gameKey); + const { id, playTimeInSeconds, ...rest } = res; + gamesSublevel.put(gameKey, { - ...(game ?? { remoteId: null }), - ...res, + ...game, + ...rest, + remoteId: id, + playTimeInMilliseconds: playTimeInSeconds * 1000, }); return res; diff --git a/src/types/index.ts b/src/types/index.ts index 2cb3618f..0a1cb713 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -344,8 +344,8 @@ export type LibraryGame = Game & }; export type UserGameDetails = ShopAssets & { - userId: string; - playTimeInMilliseconds: number; + id: string; + playTimeInSeconds: number; unlockedAchievementCount: number; achievementsPointsEarnedSum: number; lastTimePlayed: Date | null;