feat: adding toast component

This commit is contained in:
Chubby Granny Chaser
2024-05-22 00:12:57 +01:00
parent da607fe741
commit 0162ebd133
13 changed files with 136 additions and 82 deletions

View File

@@ -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" });
});
}
};

View File

@@ -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;
}
};