diff --git a/src/components/sidebar/tabs/QueueSidebarTab.vue b/src/components/sidebar/tabs/QueueSidebarTab.vue index 71180f61a..1649f4aeb 100644 --- a/src/components/sidebar/tabs/QueueSidebarTab.vue +++ b/src/components/sidebar/tabs/QueueSidebarTab.vue @@ -59,6 +59,11 @@
+
+ +
- tasks - .map( - (task: TaskItem) => - new TaskItemImpl( - task.taskType, - task.prompt, - task['status'], - task['outputs'] || {} - ) + this.loadingHistory = true + try { + const [queue, history] = await Promise.all([ + api.getQueue(), + api.getHistory(this.maxHistoryItems) + ]) + + const toClassAll = (tasks: TaskItem[]): TaskItemImpl[] => + tasks + .map( + (task: TaskItem) => + new TaskItemImpl( + task.taskType, + task.prompt, + task['status'], + task['outputs'] || {} + ) + ) + // Desc order to show the latest tasks first + .sort((a, b) => b.queueIndex - a.queueIndex) + + this.runningTasks = toClassAll(queue.Running) + this.pendingTasks = toClassAll(queue.Pending) + + // Process history items + const allIndex = new Set( + history.History.map((item: TaskItem) => item.prompt[0]) + ) + const newHistoryItems = toClassAll( + history.History.filter( + (item) => item.prompt[0] > this.lastHistoryQueueIndex ) - // Desc order to show the latest tasks first - .sort((a, b) => b.queueIndex - a.queueIndex) - - this.runningTasks = toClassAll(queue.Running) - this.pendingTasks = toClassAll(queue.Pending) - - // Process history items - const allIndex = new Set( - history.History.map((item: TaskItem) => item.prompt[0]) - ) - 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) + 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) + } finally { + this.loadingHistory = false + } }, async clear() { await Promise.all(