mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 05:46:17 +00:00
first commit
This commit is contained in:
34
src/main/events/torrenting/pause-game-download.ts
Normal file
34
src/main/events/torrenting/pause-game-download.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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",
|
||||
});
|
||||
Reference in New Issue
Block a user