Fix delete queue item (#428)

This commit is contained in:
Chenlei Hu
2024-08-14 15:10:17 -04:00
committed by GitHub
parent d8ee0b4584
commit 00fe3515b9

View File

@@ -198,16 +198,20 @@ export const useQueueStore = defineStore('queue', {
this.pendingTasks = toClassAll(queue.Pending)
// Process history items
const newHistoryItems = history.History.filter(
(item) => item.prompt[0] > this.lastHistoryQueueIndex
const allIndex = new Set(
history.History.map((item: TaskItem) => item.prompt[0])
)
if (newHistoryItems.length > 0) {
const newProcessedItems = toClassAll(newHistoryItems)
this.historyTasks = [...newProcessedItems, ...this.historyTasks]
.slice(0, this.maxHistoryItems)
.sort((a, b) => b.queueIndex - a.queueIndex)
}
const newHistoryItems = toClassAll(
history.History.filter(
(item) => item.prompt[0] > this.lastHistoryQueueIndex
)
)
const existingHistoryItems = this.historyTasks.filter(
(item: TaskItemImpl) => allIndex.has(item.queueIndex)
)
this.historyTasks = [...newHistoryItems, ...existingHistoryItems]
.slice(0, this.maxHistoryItems)
.sort((a, b) => b.queueIndex - a.queueIndex)
},
async clear() {
await Promise.all(