Skip to content

A full-featured download manager.

refactor: update pause task speed use force pause

Dr_rOotcb845ea65afe
diff --git a/src/renderer/store/modules/task.js b/src/renderer/store/modules/task.js
index 4e1ec745..0f545bef 100644
--- a/src/renderer/store/modules/task.js
+++ b/src/renderer/store/modules/task.js
@@ -119,25 +119,28 @@ const actions = {
dispatch('saveSession')
})
},
- forcePauseTask (_, task) {
+ forcePauseTask ({ dispatch }, task) {
const { gid, status } = task
if (status !== TASK_STATUS.ACTIVE) {
return Promise.resolve(true)
}
return api.forcePauseTask({ gid })
- },
- pauseTask ({ dispatch }, task) {
- const { gid } = task
- return api.pauseTask({ gid })
- .catch(() => {
- return api.forcePauseTask({ gid })
- })
.finally(() => {
dispatch('fetchList')
dispatch('saveSession')
})
},
+ pauseTask ({ dispatch }, task) {
+ const { gid } = task
+ const isBT = checkTaskIsBT(task)
+ const promise = isBT ? api.forcePauseTask({ gid }) : api.pauseTask({ gid })
+ promise.finally(() => {
+ dispatch('fetchList')
+ dispatch('saveSession')
+ })
+ return promise
+ },
resumeTask ({ dispatch }, task) {
const { gid } = task
return api.resumeTask({ gid })