mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
27 lines
630 B
TypeScript
27 lines
630 B
TypeScript
import { gameRepository } from "@main/repository";
|
|
|
|
import { registerEvent } from "../register-event";
|
|
|
|
import type { GameShop } from "@types";
|
|
import { getImageBase64 } from "@main/helpers";
|
|
import { getSteamGameIconUrl } from "@main/services";
|
|
|
|
const addGameToLibrary = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
objectID: string,
|
|
title: string,
|
|
gameShop: GameShop,
|
|
) => {
|
|
const iconUrl = await getImageBase64(await getSteamGameIconUrl(objectID));
|
|
|
|
return gameRepository.insert({
|
|
title,
|
|
iconUrl,
|
|
objectID,
|
|
shop: gameShop,
|
|
});
|
|
};
|
|
|
|
registerEvent(addGameToLibrary, {
|
|
name: "addGameToLibrary",
|
|
});
|