Skip to content

Commit

Permalink
fix: Update task does not disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Dec 24, 2022
1 parent 44cbd1d commit 02b1d9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xmcl-keystone-ui/src/composables/taskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function useTaskManager() {

function getTaskItem(payload: TaskPayload | TaskAddedPayload): TaskItem {
const id = `${payload.uuid}@${payload.id}`
console.log(`Add task ${payload.path}(${id})`)
const item: TaskItem = {
id,
taskId: payload.uuid,
Expand Down Expand Up @@ -157,6 +158,7 @@ export function useTaskManager() {
tasks.value.unshift(item)
}
cache[id] = item
console.log(`Add task ${add.path}(${id})`)
}
for (const update of updates) {
const { uuid, id, time, to, from, progress, total, chunkSize, state, error } = update
Expand Down Expand Up @@ -190,7 +192,11 @@ export function useTaskManager() {
syncing = new Promise((resolve) => { _resolve = resolve })
taskMonitor.on('task-update', onTaskUpdate)
taskMonitor.subscribe().then((payload) => {
tasks.value = payload.map(getTaskItem)
const result = payload.map(getTaskItem)
tasks.value = result
for (const r of result) {
cache[r.id] = r
}
_resolve()
})
})
Expand Down

0 comments on commit 02b1d9a

Please sign in to comment.