mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 21:31:03 +00:00
31 lines
793 B
TypeScript
31 lines
793 B
TypeScript
import { registerEvent } from "../register-event";
|
|
import { gameRepository } from "../../repository";
|
|
import { In } from "typeorm";
|
|
import { DownloadManager, WindowManager } from "@main/services";
|
|
import { GameStatus } from "@shared";
|
|
|
|
const pauseGameDownload = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
gameId: number
|
|
) => {
|
|
DownloadManager.pauseDownload();
|
|
|
|
await gameRepository
|
|
.update(
|
|
{
|
|
id: gameId,
|
|
status: In([
|
|
GameStatus.Downloading,
|
|
GameStatus.DownloadingMetadata,
|
|
GameStatus.CheckingFiles,
|
|
]),
|
|
},
|
|
{ status: GameStatus.Paused }
|
|
)
|
|
.then((result) => {
|
|
if (result.affected) WindowManager.mainWindow?.setProgressBar(-1);
|
|
});
|
|
};
|
|
|
|
registerEvent("pauseGameDownload", pauseGameDownload);
|