refactor removeGameFromLibrary to handle error

This commit is contained in:
Zamitto 2024-06-18 21:58:11 -03:00
parent ab4cf23f97
commit b07451e91d

View file

@ -1,6 +1,7 @@
import { registerEvent } from "../register-event";
import { gameRepository } from "../../repository";
import { HydraApi } from "@main/services/hydra-api";
import { logger } from "@main/services";
const removeGameFromLibrary = async (
_event: Electron.IpcMainInvokeEvent,
@ -11,6 +12,12 @@ const removeGameFromLibrary = async (
{ isDeleted: true, executablePath: null }
);
removeRemoveGameFromLibrary(gameId).catch((err) => {
logger.error("removeRemoveGameFromLibrary", err);
});
};
const removeRemoveGameFromLibrary = async (gameId: number) => {
const game = await gameRepository.findOne({ where: { id: gameId } });
if (game?.remoteId) {