hydra/src/main/events/library/update-launch-options.ts
2025-01-21 10:44:43 +00:00

23 lines
611 B
TypeScript

import { registerEvent } from "../register-event";
import { gamesSublevel, levelKeys } from "@main/level";
import { GameShop } from "@types";
const updateLaunchOptions = async (
_event: Electron.IpcMainInvokeEvent,
shop: GameShop,
objectId: string,
launchOptions: string | null
) => {
const gameKey = levelKeys.game(shop, objectId);
const game = await gamesSublevel.get(gameKey);
if (game) {
await gamesSublevel.put(gameKey, {
...game,
launchOptions: launchOptions?.trim() != "" ? launchOptions : null,
});
}
};
registerEvent("updateLaunchOptions", updateLaunchOptions);