mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 01:53:57 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { registerEvent } from "../register-event";
|
|
import { gamesSublevel, gamesShopAssetsSublevel, levelKeys } from "@main/level";
|
|
import type { GameShop } from "@types";
|
|
|
|
const updateCustomGame = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
shop: GameShop,
|
|
objectId: string,
|
|
title: string,
|
|
iconUrl?: string,
|
|
logoImageUrl?: string,
|
|
libraryHeroImageUrl?: string
|
|
) => {
|
|
const gameKey = levelKeys.game(shop, objectId);
|
|
|
|
const existingGame = await gamesSublevel.get(gameKey);
|
|
if (!existingGame) {
|
|
throw new Error("Game not found");
|
|
}
|
|
|
|
const updatedGame = {
|
|
...existingGame,
|
|
title,
|
|
iconUrl: iconUrl || null,
|
|
logoImageUrl: logoImageUrl || null,
|
|
libraryHeroImageUrl: libraryHeroImageUrl || null,
|
|
};
|
|
|
|
await gamesSublevel.put(gameKey, updatedGame);
|
|
|
|
const existingAssets = await gamesShopAssetsSublevel.get(gameKey);
|
|
if (existingAssets) {
|
|
const updatedAssets = {
|
|
...existingAssets,
|
|
title,
|
|
iconUrl: iconUrl || null,
|
|
libraryHeroImageUrl: libraryHeroImageUrl || "",
|
|
libraryImageUrl: iconUrl || "",
|
|
logoImageUrl: logoImageUrl || "",
|
|
coverImageUrl: iconUrl || "",
|
|
};
|
|
|
|
await gamesShopAssetsSublevel.put(gameKey, updatedAssets);
|
|
}
|
|
|
|
return updatedGame;
|
|
};
|
|
|
|
registerEvent("updateCustomGame", updateCustomGame);
|