From 9f9e5d371a281f5d8c7cfd366b89a5a7e18efdcc Mon Sep 17 00:00:00 2001 From: waldo121 <17034517+waldo121@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:08:56 -0400 Subject: [PATCH] Fix download pausing/resume click behaviour --- packages/app/app/actions/downloads.ts | 14 ++++++++------ packages/main/src/controllers/download.ts | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/app/app/actions/downloads.ts b/packages/app/app/actions/downloads.ts index f3d36f1d7a..91c54c85ea 100644 --- a/packages/app/app/actions/downloads.ts +++ b/packages/app/app/actions/downloads.ts @@ -108,12 +108,14 @@ export const onDownloadProgress = createStandardAction(DownloadActionTypes.DOWNL propertyName: 'completion', value: progress }); - - payload = changePropertyForItem({ - downloads: payload, - uuid, - value: progress < 1 ? DownloadStatus.STARTED : DownloadStatus.FINISHED - }); + if (progress >= 1) { + payload = changePropertyForItem({ + downloads: payload, + uuid, + value: DownloadStatus.FINISHED + }); + } + return { payload diff --git a/packages/main/src/controllers/download.ts b/packages/main/src/controllers/download.ts index 377e1a6b92..218c044b42 100644 --- a/packages/main/src/controllers/download.ts +++ b/packages/main/src/controllers/download.ts @@ -59,6 +59,7 @@ class DownloadIpcCtrl { if (downloadRef) { if (downloadRef.ref.canResume()) { downloadRef.ref.resume(); + this.window?.send(IpcEvents.DOWNLOAD_STARTED, uuid); return; } this.downloadItems = this.downloadItems.filter((item => item.uuid === uuid)); @@ -80,6 +81,7 @@ class DownloadIpcCtrl { this.downloadItems = this.downloadItems.filter((item) => item.uuid !== uuid); this.downloadItems.push({ uuid, ref: item }); this.logger.log(`Download started: ${filename}`); + this.window?.send(IpcEvents.DOWNLOAD_STARTED, uuid); }, onProgress: (progress) => { this.window.send(IpcEvents.DOWNLOAD_PROGRESS, {