From 56217fbcf82cb3ce48d681c2cc23d43cfbf009d1 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:38:50 -0300 Subject: [PATCH] fix: bug after pause seed --- python_rpc/main.py | 7 +++++-- src/main/services/download/download-manager.ts | 16 +++++++--------- .../src/pages/downloads/download-group.tsx | 5 ++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/python_rpc/main.py b/python_rpc/main.py index 028e9fa3..ed4e7c4f 100644 --- a/python_rpc/main.py +++ b/python_rpc/main.py @@ -59,12 +59,15 @@ def seed_status(): return auth_error seed_status = [] + for game_id, downloader in downloads.items(): if not downloader: continue - + response = downloader.get_download_status() - + if response is None: + continue + if response.get('status') == 5: seed_status.append({ 'gameId': game_id, diff --git a/src/main/services/download/download-manager.ts b/src/main/services/download/download-manager.ts index 78452380..daa69113 100644 --- a/src/main/services/download/download-manager.ts +++ b/src/main/services/download/download-manager.ts @@ -158,13 +158,14 @@ export class DownloadManager { } public static async getSeedStatus() { - const seedStatus = await PythonRPC.rpc.get( - "/seed-status" - ); + const seedStatus = await PythonRPC.rpc + .get("/seed-status") + .then((res) => res.data); - if (!seedStatus.data.length) return; + console.log(seedStatus); + if (!seedStatus.length) return; - seedStatus.data.forEach(async (status) => { + seedStatus.forEach(async (status) => { const game = await gameRepository.findOne({ where: { id: status.gameId }, }); @@ -188,10 +189,7 @@ export class DownloadManager { } }); - WindowManager.mainWindow?.webContents.send( - "on-seeding-status", - JSON.parse(JSON.stringify(seedStatus.data)) - ); + WindowManager.mainWindow?.webContents.send("on-seeding-status", seedStatus); } static async pauseDownload() { diff --git a/src/renderer/src/pages/downloads/download-group.tsx b/src/renderer/src/pages/downloads/download-group.tsx index e9ae8a82..88cf1433 100644 --- a/src/renderer/src/pages/downloads/download-group.tsx +++ b/src/renderer/src/pages/downloads/download-group.tsx @@ -77,13 +77,12 @@ export function DownloadGroup({ }; const seedingMap = useMemo(() => { - if (!Array.isArray(seedingStatus) || seedingStatus.length === 0) { - return new Map(); - } const map = new Map(); + seedingStatus.forEach((seed) => { map.set(seed.gameId, seed); }); + return map; }, [seedingStatus]);