From 0f3d6ef76f36e4b10f8d9dd4060d4f3bcf6d8320 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Tue, 30 Sep 2025 01:18:44 +0300 Subject: [PATCH 1/5] fix: state fix and remake checking for overlap --- .../pages/game-details/modals/edit-game-modal.tsx | 13 +++++++++---- .../profile-content/user-library-game-card.tsx | 11 +++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx index 2413cb9e..e55772c6 100644 --- a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx @@ -84,7 +84,10 @@ export function EditGameModal({ setDefaultUrls({ icon: shopDetails?.assets?.iconUrl || game.iconUrl || null, logo: shopDetails?.assets?.logoImageUrl || game.logoImageUrl || null, - hero: shopDetails?.assets?.libraryHeroImageUrl || game.libraryHeroImageUrl || null, + hero: + shopDetails?.assets?.libraryHeroImageUrl || + game.libraryHeroImageUrl || + null, }); }, [shopDetails] @@ -119,11 +122,11 @@ export function EditGameModal({ }; const setAssetPath = (assetType: AssetType, path: string): void => { - setAssetPaths(prev => ({ ...prev, [assetType]: path })); + setAssetPaths((prev) => ({ ...prev, [assetType]: path })); }; const setAssetDisplayPath = (assetType: AssetType, path: string): void => { - setAssetDisplayPaths(prev => ({ ...prev, [assetType]: path })); + setAssetDisplayPaths((prev) => ({ ...prev, [assetType]: path })); }; const getDefaultUrl = (assetType: AssetType): string | null => { @@ -293,7 +296,9 @@ export function EditGameModal({ // Helper function to prepare custom game assets const prepareCustomGameAssets = (game: LibraryGame | Game) => { const iconUrl = assetPaths.icon ? `local:${assetPaths.icon}` : game.iconUrl; - const logoImageUrl = assetPaths.logo ? `local:${assetPaths.logo}` : game.logoImageUrl; + const logoImageUrl = assetPaths.logo + ? `local:${assetPaths.logo}` + : game.logoImageUrl; const libraryHeroImageUrl = assetPaths.hero ? `local:${assetPaths.hero}` : game.libraryHeroImageUrl; diff --git a/src/renderer/src/pages/profile/profile-content/user-library-game-card.tsx b/src/renderer/src/pages/profile/profile-content/user-library-game-card.tsx index ec7736e0..251a3bc7 100644 --- a/src/renderer/src/pages/profile/profile-content/user-library-game-card.tsx +++ b/src/renderer/src/pages/profile/profile-content/user-library-game-card.tsx @@ -44,7 +44,6 @@ export function UserLibraryGameCard({ const [isTooltipHovered, setIsTooltipHovered] = useState(false); const [isPinning, setIsPinning] = useState(false); - const getStatsItemCount = useCallback(() => { let statsCount = 1; if (game.achievementsPointsEarnedSum > 0) statsCount++; @@ -91,15 +90,15 @@ export function UserLibraryGameCard({ const hours = minutes / 60; const hoursKey = isShort ? "amount_hours_short" : "amount_hours"; - const hoursAmount = isShort ? Math.floor(hours) : numberFormatter.format(hours); - + const hoursAmount = isShort + ? Math.floor(hours) + : numberFormatter.format(hours); + return t(hoursKey, { amount: hoursAmount }); }, [numberFormatter, t] ); - - const toggleGamePinned = async () => { setIsPinning(true); @@ -162,7 +161,7 @@ export function UserLibraryGameCard({ )} )} -
Date: Tue, 30 Sep 2025 01:43:13 +0300 Subject: [PATCH 2/5] fix: playtime font-size increased --- .../pages/profile/profile-content/user-library-game-card.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/src/pages/profile/profile-content/user-library-game-card.scss b/src/renderer/src/pages/profile/profile-content/user-library-game-card.scss index dccd9dd1..a19961fd 100644 --- a/src/renderer/src/pages/profile/profile-content/user-library-game-card.scss +++ b/src/renderer/src/pages/profile/profile-content/user-library-game-card.scss @@ -164,10 +164,12 @@ &-long { display: inline; + font-size: 12px; } &-short { display: none; + font-size: 12px; } // When the card is narrow (less than 180px), show short format From 959bed746b75f74217ee9fc052427f742a4d0f40 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Tue, 30 Sep 2025 02:09:19 +0300 Subject: [PATCH 3/5] fix: original path to image not showing in modal after updating game asset --- src/main/events/library/update-custom-game.ts | 8 ++++- .../library/update-game-custom-assets.ts | 18 +++++++++-- src/preload/index.ts | 20 +++++++++--- src/renderer/src/declaration.d.ts | 10 ++++-- .../game-details/modals/edit-game-modal.tsx | 32 +++++++++++++++++-- src/types/level.types.ts | 6 ++++ 6 files changed, 81 insertions(+), 13 deletions(-) diff --git a/src/main/events/library/update-custom-game.ts b/src/main/events/library/update-custom-game.ts index 82d7f45f..62473e54 100644 --- a/src/main/events/library/update-custom-game.ts +++ b/src/main/events/library/update-custom-game.ts @@ -11,7 +11,10 @@ const updateCustomGame = async ( title: string, iconUrl?: string, logoImageUrl?: string, - libraryHeroImageUrl?: string + libraryHeroImageUrl?: string, + originalIconPath?: string, + originalLogoPath?: string, + originalHeroPath?: string ) => { const gameKey = levelKeys.game(shop, objectId); @@ -40,6 +43,9 @@ const updateCustomGame = async ( iconUrl: iconUrl || null, logoImageUrl: logoImageUrl || null, libraryHeroImageUrl: libraryHeroImageUrl || null, + originalIconPath: originalIconPath || existingGame.originalIconPath || null, + originalLogoPath: originalLogoPath || existingGame.originalLogoPath || null, + originalHeroPath: originalHeroPath || existingGame.originalHeroPath || null, }; await gamesSublevel.put(gameKey, updatedGame); diff --git a/src/main/events/library/update-game-custom-assets.ts b/src/main/events/library/update-game-custom-assets.ts index 4bd4e517..8cfc79f0 100644 --- a/src/main/events/library/update-game-custom-assets.ts +++ b/src/main/events/library/update-game-custom-assets.ts @@ -38,7 +38,10 @@ const updateGameData = async ( title: string, customIconUrl?: string | null, customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null + customHeroImageUrl?: string | null, + customOriginalIconPath?: string | null, + customOriginalLogoPath?: string | null, + customOriginalHeroPath?: string | null ): Promise => { const updatedGame = { ...existingGame, @@ -46,6 +49,9 @@ const updateGameData = async ( ...(customIconUrl !== undefined && { customIconUrl }), ...(customLogoImageUrl !== undefined && { customLogoImageUrl }), ...(customHeroImageUrl !== undefined && { customHeroImageUrl }), + ...(customOriginalIconPath !== undefined && { customOriginalIconPath }), + ...(customOriginalLogoPath !== undefined && { customOriginalLogoPath }), + ...(customOriginalHeroPath !== undefined && { customOriginalHeroPath }), }; await gamesSublevel.put(gameKey, updatedGame); @@ -87,7 +93,10 @@ const updateGameCustomAssets = async ( title: string, customIconUrl?: string | null, customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null + customHeroImageUrl?: string | null, + customOriginalIconPath?: string | null, + customOriginalLogoPath?: string | null, + customOriginalHeroPath?: string | null ) => { const gameKey = levelKeys.game(shop, objectId); @@ -109,7 +118,10 @@ const updateGameCustomAssets = async ( title, customIconUrl, customLogoImageUrl, - customHeroImageUrl + customHeroImageUrl, + customOriginalIconPath, + customOriginalLogoPath, + customOriginalHeroPath ); await updateShopAssets(gameKey, title); diff --git a/src/preload/index.ts b/src/preload/index.ts index e536f8c7..e4a29c90 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -158,7 +158,10 @@ contextBridge.exposeInMainWorld("electron", { title: string, iconUrl?: string, logoImageUrl?: string, - libraryHeroImageUrl?: string + libraryHeroImageUrl?: string, + originalIconPath?: string, + originalLogoPath?: string, + originalHeroPath?: string ) => ipcRenderer.invoke( "updateCustomGame", @@ -167,7 +170,10 @@ contextBridge.exposeInMainWorld("electron", { title, iconUrl, logoImageUrl, - libraryHeroImageUrl + libraryHeroImageUrl, + originalIconPath, + originalLogoPath, + originalHeroPath ), updateGameCustomAssets: ( shop: GameShop, @@ -175,7 +181,10 @@ contextBridge.exposeInMainWorld("electron", { title: string, customIconUrl?: string | null, customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null + customHeroImageUrl?: string | null, + customOriginalIconPath?: string | null, + customOriginalLogoPath?: string | null, + customOriginalHeroPath?: string | null ) => ipcRenderer.invoke( "updateGameCustomAssets", @@ -184,7 +193,10 @@ contextBridge.exposeInMainWorld("electron", { title, customIconUrl, customLogoImageUrl, - customHeroImageUrl + customHeroImageUrl, + customOriginalIconPath, + customOriginalLogoPath, + customOriginalHeroPath ), createGameShortcut: ( shop: GameShop, diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 81d18940..9477edb5 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -125,7 +125,10 @@ declare global { title: string, iconUrl?: string, logoImageUrl?: string, - libraryHeroImageUrl?: string + libraryHeroImageUrl?: string, + originalIconPath?: string, + originalLogoPath?: string, + originalHeroPath?: string ) => Promise; copyCustomGameAsset: ( sourcePath: string, @@ -141,7 +144,10 @@ declare global { title: string, customIconUrl?: string | null, customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null + customHeroImageUrl?: string | null, + customOriginalIconPath?: string | null, + customOriginalLogoPath?: string | null, + customOriginalHeroPath?: string | null ) => Promise; createGameShortcut: ( shop: GameShop, diff --git a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx index e55772c6..37801c6f 100644 --- a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx @@ -39,6 +39,11 @@ export function EditGameModal({ logo: "", hero: "", }); + const [originalAssetPaths, setOriginalAssetPaths] = useState({ + icon: "", + logo: "", + hero: "", + }); const [defaultUrls, setDefaultUrls] = useState({ icon: null as string | null, logo: null as string | null, @@ -66,6 +71,11 @@ export function EditGameModal({ logo: extractLocalPath(game.logoImageUrl), hero: extractLocalPath(game.libraryHeroImageUrl), }); + setOriginalAssetPaths({ + icon: (game as any).originalIconPath || extractLocalPath(game.iconUrl), + logo: (game as any).originalLogoPath || extractLocalPath(game.logoImageUrl), + hero: (game as any).originalHeroPath || extractLocalPath(game.libraryHeroImageUrl), + }); }, []); const setNonCustomGameAssets = useCallback( @@ -80,6 +90,11 @@ export function EditGameModal({ logo: extractLocalPath(game.customLogoImageUrl), hero: extractLocalPath(game.customHeroImageUrl), }); + setOriginalAssetPaths({ + icon: (game as any).customOriginalIconPath || extractLocalPath(game.customIconUrl), + logo: (game as any).customOriginalLogoPath || extractLocalPath(game.customLogoImageUrl), + hero: (game as any).customOriginalHeroPath || extractLocalPath(game.customHeroImageUrl), + }); setDefaultUrls({ icon: shopDetails?.assets?.iconUrl || game.iconUrl || null, @@ -118,7 +133,8 @@ export function EditGameModal({ }; const getAssetDisplayPath = (assetType: AssetType): string => { - return assetDisplayPaths[assetType]; + // Use original path if available, otherwise fall back to display path + return originalAssetPaths[assetType] || assetDisplayPaths[assetType]; }; const setAssetPath = (assetType: AssetType, path: string): void => { @@ -153,10 +169,13 @@ export function EditGameModal({ ); setAssetPath(assetType, copiedAssetUrl.replace("local:", "")); setAssetDisplayPath(assetType, originalPath); + // Store the original path for display purposes + setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: originalPath })); } catch (error) { console.error(`Failed to copy ${assetType} asset:`, error); setAssetPath(assetType, originalPath); setAssetDisplayPath(assetType, originalPath); + setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: originalPath })); } } }; @@ -164,6 +183,7 @@ export function EditGameModal({ const handleRestoreDefault = (assetType: AssetType) => { setAssetPath(assetType, ""); setAssetDisplayPath(assetType, ""); + setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: "" })); }; const getOriginalTitle = (): string => { @@ -326,7 +346,10 @@ export function EditGameModal({ gameName.trim(), iconUrl || undefined, logoImageUrl || undefined, - libraryHeroImageUrl || undefined + libraryHeroImageUrl || undefined, + originalAssetPaths.icon || undefined, + originalAssetPaths.logo || undefined, + originalAssetPaths.hero || undefined ); }; @@ -341,7 +364,10 @@ export function EditGameModal({ gameName.trim(), customIconUrl, customLogoImageUrl, - customHeroImageUrl + customHeroImageUrl, + originalAssetPaths.icon || undefined, + originalAssetPaths.logo || undefined, + originalAssetPaths.hero || undefined ); }; diff --git a/src/types/level.types.ts b/src/types/level.types.ts index 73fce370..8a6c56a0 100644 --- a/src/types/level.types.ts +++ b/src/types/level.types.ts @@ -38,6 +38,12 @@ export interface Game { customIconUrl?: string | null; customLogoImageUrl?: string | null; customHeroImageUrl?: string | null; + originalIconPath?: string | null; + originalLogoPath?: string | null; + originalHeroPath?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; playTimeInMilliseconds: number; unsyncedDeltaPlayTimeInMilliseconds?: number; lastTimePlayed: Date | null; From ceb236c40c0bae6e3d97ef0f844d54d9f40baa13 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Tue, 30 Sep 2025 02:17:17 +0300 Subject: [PATCH 4/5] fix: async error function had too many arguments --- src/main/events/library/update-custom-game.ts | 33 ++++++--- .../library/update-game-custom-assets.ts | 72 +++++++++++++------ src/preload/index.ts | 68 ++++++------------ src/renderer/src/declaration.d.ts | 44 ++++++------ .../game-details/modals/edit-game-modal.tsx | 67 ++++++++++------- 5 files changed, 160 insertions(+), 124 deletions(-) diff --git a/src/main/events/library/update-custom-game.ts b/src/main/events/library/update-custom-game.ts index 62473e54..8129fc57 100644 --- a/src/main/events/library/update-custom-game.ts +++ b/src/main/events/library/update-custom-game.ts @@ -4,18 +4,33 @@ import type { GameShop } from "@types"; import fs from "node:fs"; import { logger } from "@main/services"; +interface UpdateCustomGameParams { + shop: GameShop; + objectId: string; + title: string; + iconUrl?: string; + logoImageUrl?: string; + libraryHeroImageUrl?: string; + originalIconPath?: string; + originalLogoPath?: string; + originalHeroPath?: string; +} + const updateCustomGame = async ( _event: Electron.IpcMainInvokeEvent, - shop: GameShop, - objectId: string, - title: string, - iconUrl?: string, - logoImageUrl?: string, - libraryHeroImageUrl?: string, - originalIconPath?: string, - originalLogoPath?: string, - originalHeroPath?: string + params: UpdateCustomGameParams ) => { + const { + shop, + objectId, + title, + iconUrl, + logoImageUrl, + libraryHeroImageUrl, + originalIconPath, + originalLogoPath, + originalHeroPath, + } = params; const gameKey = levelKeys.game(shop, objectId); const existingGame = await gamesSublevel.get(gameKey); diff --git a/src/main/events/library/update-game-custom-assets.ts b/src/main/events/library/update-game-custom-assets.ts index 8cfc79f0..57b14775 100644 --- a/src/main/events/library/update-game-custom-assets.ts +++ b/src/main/events/library/update-game-custom-assets.ts @@ -32,17 +32,32 @@ const collectOldAssetPaths = ( return oldAssetPaths; }; +interface UpdateGameDataParams { + gameKey: string; + existingGame: Game; + title: string; + customIconUrl?: string | null; + customLogoImageUrl?: string | null; + customHeroImageUrl?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; +} + const updateGameData = async ( - gameKey: string, - existingGame: Game, - title: string, - customIconUrl?: string | null, - customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null, - customOriginalIconPath?: string | null, - customOriginalLogoPath?: string | null, - customOriginalHeroPath?: string | null + params: UpdateGameDataParams ): Promise => { + const { + gameKey, + existingGame, + title, + customIconUrl, + customLogoImageUrl, + customHeroImageUrl, + customOriginalIconPath, + customOriginalLogoPath, + customOriginalHeroPath, + } = params; const updatedGame = { ...existingGame, title, @@ -86,18 +101,33 @@ const deleteOldAssetFiles = async (oldAssetPaths: string[]): Promise => { } }; +interface UpdateGameCustomAssetsParams { + shop: GameShop; + objectId: string; + title: string; + customIconUrl?: string | null; + customLogoImageUrl?: string | null; + customHeroImageUrl?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; +} + const updateGameCustomAssets = async ( _event: Electron.IpcMainInvokeEvent, - shop: GameShop, - objectId: string, - title: string, - customIconUrl?: string | null, - customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null, - customOriginalIconPath?: string | null, - customOriginalLogoPath?: string | null, - customOriginalHeroPath?: string | null + params: UpdateGameCustomAssetsParams ) => { + const { + shop, + objectId, + title, + customIconUrl, + customLogoImageUrl, + customHeroImageUrl, + customOriginalIconPath, + customOriginalLogoPath, + customOriginalHeroPath, + } = params; const gameKey = levelKeys.game(shop, objectId); const existingGame = await gamesSublevel.get(gameKey); @@ -112,7 +142,7 @@ const updateGameCustomAssets = async ( customHeroImageUrl ); - const updatedGame = await updateGameData( + const updatedGame = await updateGameData({ gameKey, existingGame, title, @@ -121,8 +151,8 @@ const updateGameCustomAssets = async ( customHeroImageUrl, customOriginalIconPath, customOriginalLogoPath, - customOriginalHeroPath - ); + customOriginalHeroPath, + }); await updateShopAssets(gameKey, title); diff --git a/src/preload/index.ts b/src/preload/index.ts index e4a29c90..b92ba137 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -152,52 +152,28 @@ contextBridge.exposeInMainWorld("electron", { deleteTempFile: (filePath: string) => ipcRenderer.invoke("deleteTempFile", filePath), cleanupUnusedAssets: () => ipcRenderer.invoke("cleanupUnusedAssets"), - updateCustomGame: ( - shop: GameShop, - objectId: string, - title: string, - iconUrl?: string, - logoImageUrl?: string, - libraryHeroImageUrl?: string, - originalIconPath?: string, - originalLogoPath?: string, - originalHeroPath?: string - ) => - ipcRenderer.invoke( - "updateCustomGame", - shop, - objectId, - title, - iconUrl, - logoImageUrl, - libraryHeroImageUrl, - originalIconPath, - originalLogoPath, - originalHeroPath - ), - updateGameCustomAssets: ( - shop: GameShop, - objectId: string, - title: string, - customIconUrl?: string | null, - customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null, - customOriginalIconPath?: string | null, - customOriginalLogoPath?: string | null, - customOriginalHeroPath?: string | null - ) => - ipcRenderer.invoke( - "updateGameCustomAssets", - shop, - objectId, - title, - customIconUrl, - customLogoImageUrl, - customHeroImageUrl, - customOriginalIconPath, - customOriginalLogoPath, - customOriginalHeroPath - ), + updateCustomGame: (params: { + shop: GameShop; + objectId: string; + title: string; + iconUrl?: string; + logoImageUrl?: string; + libraryHeroImageUrl?: string; + originalIconPath?: string; + originalLogoPath?: string; + originalHeroPath?: string; + }) => ipcRenderer.invoke("updateCustomGame", params), + updateGameCustomAssets: (params: { + shop: GameShop; + objectId: string; + title: string; + customIconUrl?: string | null; + customLogoImageUrl?: string | null; + customHeroImageUrl?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; + }) => ipcRenderer.invoke("updateGameCustomAssets", params), createGameShortcut: ( shop: GameShop, objectId: string, diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 9477edb5..e6277888 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -119,17 +119,17 @@ declare global { logoImageUrl?: string, libraryHeroImageUrl?: string ) => Promise; - updateCustomGame: ( - shop: GameShop, - objectId: string, - title: string, - iconUrl?: string, - logoImageUrl?: string, - libraryHeroImageUrl?: string, - originalIconPath?: string, - originalLogoPath?: string, - originalHeroPath?: string - ) => Promise; + updateCustomGame: (params: { + shop: GameShop; + objectId: string; + title: string; + iconUrl?: string; + logoImageUrl?: string; + libraryHeroImageUrl?: string; + originalIconPath?: string; + originalLogoPath?: string; + originalHeroPath?: string; + }) => Promise; copyCustomGameAsset: ( sourcePath: string, assetType: "icon" | "logo" | "hero" @@ -138,17 +138,17 @@ declare global { deletedCount: number; errors: string[]; }>; - updateGameCustomAssets: ( - shop: GameShop, - objectId: string, - title: string, - customIconUrl?: string | null, - customLogoImageUrl?: string | null, - customHeroImageUrl?: string | null, - customOriginalIconPath?: string | null, - customOriginalLogoPath?: string | null, - customOriginalHeroPath?: string | null - ) => Promise; + updateGameCustomAssets: (params: { + shop: GameShop; + objectId: string; + title: string; + customIconUrl?: string | null; + customLogoImageUrl?: string | null; + customHeroImageUrl?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; + }) => Promise; createGameShortcut: ( shop: GameShop, objectId: string, diff --git a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx index 37801c6f..0f6df95d 100644 --- a/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/edit-game-modal.tsx @@ -73,8 +73,11 @@ export function EditGameModal({ }); setOriginalAssetPaths({ icon: (game as any).originalIconPath || extractLocalPath(game.iconUrl), - logo: (game as any).originalLogoPath || extractLocalPath(game.logoImageUrl), - hero: (game as any).originalHeroPath || extractLocalPath(game.libraryHeroImageUrl), + logo: + (game as any).originalLogoPath || extractLocalPath(game.logoImageUrl), + hero: + (game as any).originalHeroPath || + extractLocalPath(game.libraryHeroImageUrl), }); }, []); @@ -91,9 +94,15 @@ export function EditGameModal({ hero: extractLocalPath(game.customHeroImageUrl), }); setOriginalAssetPaths({ - icon: (game as any).customOriginalIconPath || extractLocalPath(game.customIconUrl), - logo: (game as any).customOriginalLogoPath || extractLocalPath(game.customLogoImageUrl), - hero: (game as any).customOriginalHeroPath || extractLocalPath(game.customHeroImageUrl), + icon: + (game as any).customOriginalIconPath || + extractLocalPath(game.customIconUrl), + logo: + (game as any).customOriginalLogoPath || + extractLocalPath(game.customLogoImageUrl), + hero: + (game as any).customOriginalHeroPath || + extractLocalPath(game.customHeroImageUrl), }); setDefaultUrls({ @@ -170,12 +179,18 @@ export function EditGameModal({ setAssetPath(assetType, copiedAssetUrl.replace("local:", "")); setAssetDisplayPath(assetType, originalPath); // Store the original path for display purposes - setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: originalPath })); + setOriginalAssetPaths((prev) => ({ + ...prev, + [assetType]: originalPath, + })); } catch (error) { console.error(`Failed to copy ${assetType} asset:`, error); setAssetPath(assetType, originalPath); setAssetDisplayPath(assetType, originalPath); - setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: originalPath })); + setOriginalAssetPaths((prev) => ({ + ...prev, + [assetType]: originalPath, + })); } } }; @@ -340,17 +355,17 @@ export function EditGameModal({ const { iconUrl, logoImageUrl, libraryHeroImageUrl } = prepareCustomGameAssets(game); - return window.electron.updateCustomGame( - game.shop, - game.objectId, - gameName.trim(), - iconUrl || undefined, - logoImageUrl || undefined, - libraryHeroImageUrl || undefined, - originalAssetPaths.icon || undefined, - originalAssetPaths.logo || undefined, - originalAssetPaths.hero || undefined - ); + return window.electron.updateCustomGame({ + shop: game.shop, + objectId: game.objectId, + title: gameName.trim(), + iconUrl: iconUrl || undefined, + logoImageUrl: logoImageUrl || undefined, + libraryHeroImageUrl: libraryHeroImageUrl || undefined, + originalIconPath: originalAssetPaths.icon || undefined, + originalLogoPath: originalAssetPaths.logo || undefined, + originalHeroPath: originalAssetPaths.hero || undefined, + }); }; // Helper function to update non-custom game @@ -358,17 +373,17 @@ export function EditGameModal({ const { customIconUrl, customLogoImageUrl, customHeroImageUrl } = prepareNonCustomGameAssets(); - return window.electron.updateGameCustomAssets( - game.shop, - game.objectId, - gameName.trim(), + return window.electron.updateGameCustomAssets({ + shop: game.shop, + objectId: game.objectId, + title: gameName.trim(), customIconUrl, customLogoImageUrl, customHeroImageUrl, - originalAssetPaths.icon || undefined, - originalAssetPaths.logo || undefined, - originalAssetPaths.hero || undefined - ); + customOriginalIconPath: originalAssetPaths.icon || undefined, + customOriginalLogoPath: originalAssetPaths.logo || undefined, + customOriginalHeroPath: originalAssetPaths.hero || undefined, + }); }; const handleUpdateGame = async () => { From e5646240abdbb08a6972c49078afdfc8ca45c679 Mon Sep 17 00:00:00 2001 From: Moyasee Date: Tue, 30 Sep 2025 02:18:22 +0300 Subject: [PATCH 5/5] fix: async error function had too many arguments --- .../library/update-game-custom-assets.ts | 4 +--- src/preload/index.ts | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/events/library/update-game-custom-assets.ts b/src/main/events/library/update-game-custom-assets.ts index 57b14775..1f912901 100644 --- a/src/main/events/library/update-game-custom-assets.ts +++ b/src/main/events/library/update-game-custom-assets.ts @@ -44,9 +44,7 @@ interface UpdateGameDataParams { customOriginalHeroPath?: string | null; } -const updateGameData = async ( - params: UpdateGameDataParams -): Promise => { +const updateGameData = async (params: UpdateGameDataParams): Promise => { const { gameKey, existingGame, diff --git a/src/preload/index.ts b/src/preload/index.ts index b92ba137..17c1225f 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -164,16 +164,16 @@ contextBridge.exposeInMainWorld("electron", { originalHeroPath?: string; }) => ipcRenderer.invoke("updateCustomGame", params), updateGameCustomAssets: (params: { - shop: GameShop; - objectId: string; - title: string; - customIconUrl?: string | null; - customLogoImageUrl?: string | null; - customHeroImageUrl?: string | null; - customOriginalIconPath?: string | null; - customOriginalLogoPath?: string | null; - customOriginalHeroPath?: string | null; - }) => ipcRenderer.invoke("updateGameCustomAssets", params), + shop: GameShop; + objectId: string; + title: string; + customIconUrl?: string | null; + customLogoImageUrl?: string | null; + customHeroImageUrl?: string | null; + customOriginalIconPath?: string | null; + customOriginalLogoPath?: string | null; + customOriginalHeroPath?: string | null; + }) => ipcRenderer.invoke("updateGameCustomAssets", params), createGameShortcut: ( shop: GameShop, objectId: string,