mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-10 05:16:19 +00:00
35 lines
836 B
TypeScript
35 lines
836 B
TypeScript
import { WindowManager, writePipe } from "@main/services";
|
|
|
|
import { registerEvent } from "../register-event";
|
|
import { GameStatus } from "../../constants";
|
|
import { gameRepository } from "../../repository";
|
|
import { In } from "typeorm";
|
|
|
|
const pauseGameDownload = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
gameId: number
|
|
) => {
|
|
await gameRepository
|
|
.update(
|
|
{
|
|
id: gameId,
|
|
status: In([
|
|
GameStatus.Downloading,
|
|
GameStatus.DownloadingMetadata,
|
|
GameStatus.CheckingFiles,
|
|
]),
|
|
},
|
|
{ status: GameStatus.Paused }
|
|
)
|
|
.then((result) => {
|
|
if (result.affected) {
|
|
writePipe.write({ action: "pause" });
|
|
WindowManager.mainWindow.setProgressBar(-1);
|
|
}
|
|
});
|
|
};
|
|
|
|
registerEvent(pauseGameDownload, {
|
|
name: "pauseGameDownload",
|
|
});
|