mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-18 00:33:59 +00:00
30 lines
828 B
TypeScript
30 lines
828 B
TypeScript
import { registerEvent } from "../register-event";
|
|
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
|
import { gamesSublevel, levelKeys } from "@main/level";
|
|
import type { GameShop } from "@types";
|
|
|
|
const updateExecutablePath = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
shop: GameShop,
|
|
objectId: string,
|
|
executablePath: string | null
|
|
) => {
|
|
const parsedPath = executablePath
|
|
? parseExecutablePath(executablePath)
|
|
: null;
|
|
|
|
const gameKey = levelKeys.game(shop, objectId);
|
|
|
|
const game = await gamesSublevel.get(gameKey);
|
|
if (!game) return;
|
|
|
|
await gamesSublevel.put(gameKey, {
|
|
...game,
|
|
executablePath: parsedPath,
|
|
automaticCloudSync:
|
|
executablePath === null ? false : game.automaticCloudSync,
|
|
});
|
|
};
|
|
|
|
registerEvent("updateExecutablePath", updateExecutablePath);
|