fix: fixing download cancel

This commit is contained in:
Chubby Granny Chaser
2025-02-16 03:01:47 +00:00
parent ae159a4d44
commit ba6eb2ecc8
3 changed files with 38 additions and 32 deletions

View File

@@ -2,7 +2,7 @@ import { registerEvent } from "../register-event";
import { DownloadManager } from "@main/services";
import { GameShop } from "@types";
import { downloadsSublevel, levelKeys } from "@main/level";
import { levelKeys } from "@main/level";
const cancelGameDownload = async (
_event: Electron.IpcMainInvokeEvent,
@@ -12,8 +12,6 @@ const cancelGameDownload = async (
const downloadKey = levelKeys.game(shop, objectId);
await DownloadManager.cancelDownload(downloadKey);
await downloadsSublevel.del(downloadKey);
};
registerEvent("cancelGameDownload", cancelGameDownload);

View File

@@ -228,14 +228,17 @@ export class DownloadManager {
}
static async cancelDownload(downloadKey = this.downloadingGameId) {
await PythonRPC.rpc.post("/action", {
action: "cancel",
game_id: downloadKey,
});
WindowManager.mainWindow?.setProgressBar(-1);
await PythonRPC.rpc
.post("/action", {
action: "cancel",
game_id: downloadKey,
})
.catch((err) => {
logger.error("Failed to cancel game download", err);
});
if (downloadKey === this.downloadingGameId) {
WindowManager.mainWindow?.setProgressBar(-1);
WindowManager.mainWindow?.webContents.send("on-download-progress", null);
this.downloadingGameId = null;
}