mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 20:31:03 +00:00
feat: adding toast component
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { Not } from "typeorm";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { Game } from "@main/entity";
|
||||
|
||||
const resumeGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@@ -18,11 +22,19 @@ const resumeGameDownload = async (
|
||||
if (!game) return;
|
||||
|
||||
if (game.status === "paused") {
|
||||
await DownloadManager.pauseDownload();
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await gameRepository.update({ id: gameId }, { status: "active" });
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ status: "active", progress: Not(1) }, { status: "paused" });
|
||||
|
||||
await DownloadManager.resumeDownload(gameId);
|
||||
await DownloadManager.resumeDownload(gameId);
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "active" });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ const startGameDownload = async (
|
||||
|
||||
if (!repack || game?.status === "active") return;
|
||||
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await gameRepository.update(
|
||||
{ status: "active", progress: Not(1) },
|
||||
{ status: "paused" }
|
||||
@@ -65,9 +67,7 @@ const startGameDownload = async (
|
||||
|
||||
await DownloadManager.startDownload(game.id);
|
||||
|
||||
game.status = "active";
|
||||
|
||||
return game;
|
||||
return { ...game, stauts: "active" };
|
||||
} else {
|
||||
const steamGame = stateManager
|
||||
.getValue("steamGames")
|
||||
@@ -98,11 +98,9 @@ const startGameDownload = async (
|
||||
return result;
|
||||
});
|
||||
|
||||
DownloadManager.startDownload(createdGame.id);
|
||||
await DownloadManager.startDownload(createdGame.id);
|
||||
|
||||
const { repack: _, ...rest } = createdGame;
|
||||
|
||||
return rest;
|
||||
return createdGame;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user