Skip to content

Commit 00fe351

Browse files
authored
Fix delete queue item (#428)
1 parent d8ee0b4 commit 00fe351

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/stores/queueStore.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,20 @@ export const useQueueStore = defineStore('queue', {
198198
this.pendingTasks = toClassAll(queue.Pending)
199199

200200
// Process history items
201-
const newHistoryItems = history.History.filter(
202-
(item) => item.prompt[0] > this.lastHistoryQueueIndex
201+
const allIndex = new Set(
202+
history.History.map((item: TaskItem) => item.prompt[0])
203203
)
204-
205-
if (newHistoryItems.length > 0) {
206-
const newProcessedItems = toClassAll(newHistoryItems)
207-
this.historyTasks = [...newProcessedItems, ...this.historyTasks]
208-
.slice(0, this.maxHistoryItems)
209-
.sort((a, b) => b.queueIndex - a.queueIndex)
210-
}
204+
const newHistoryItems = toClassAll(
205+
history.History.filter(
206+
(item) => item.prompt[0] > this.lastHistoryQueueIndex
207+
)
208+
)
209+
const existingHistoryItems = this.historyTasks.filter(
210+
(item: TaskItemImpl) => allIndex.has(item.queueIndex)
211+
)
212+
this.historyTasks = [...newHistoryItems, ...existingHistoryItems]
213+
.slice(0, this.maxHistoryItems)
214+
.sort((a, b) => b.queueIndex - a.queueIndex)
211215
},
212216
async clear() {
213217
await Promise.all(

0 commit comments

Comments
 (0)