Add button to clear pending tasks (#810)

This commit is contained in:
Chenlei Hu
2024-09-13 10:23:28 +09:00
committed by GitHub
parent 880ac4fa5a
commit d8d6fa86e4
3 changed files with 31 additions and 6 deletions

View File

@@ -277,6 +277,9 @@ export const useQueueStore = defineStore('queue', {
},
lastHistoryQueueIndex(state) {
return state.historyTasks.length ? state.historyTasks[0].queueIndex : -1
},
hasPendingTasks(state) {
return state.pendingTasks.length > 0
}
},
actions: {
@@ -325,10 +328,11 @@ export const useQueueStore = defineStore('queue', {
this.isLoading = false
}
},
async clear() {
await Promise.all(
['queue', 'history'].map((type) => api.clearItems(type))
)
async clear(targets: ('queue' | 'history')[] = ['queue', 'history']) {
if (targets.length === 0) {
return
}
await Promise.all(targets.map((type) => api.clearItems(type)))
await this.update()
},
async delete(task: TaskItemImpl) {