From c1c5573e7f538a76d817d2c83854377079ffcd80 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 25 Nov 2024 09:59:10 -0800 Subject: [PATCH] Fix queue sidebar tab task filter (#1682) * Fix queue sidebar tab task filter * nit --- .../sidebar/tabs/QueueSidebarTab.vue | 44 +++++++++---------- src/stores/queueStore.ts | 6 +++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/components/sidebar/tabs/QueueSidebarTab.vue b/src/components/sidebar/tabs/QueueSidebarTab.vue index 23b4ba094..4717cbad0 100644 --- a/src/components/sidebar/tabs/QueueSidebarTab.vue +++ b/src/components/sidebar/tabs/QueueSidebarTab.vue @@ -118,7 +118,11 @@ import OutputFilters from './queue/OutputFilters.vue' import ResultGallery from './queue/ResultGallery.vue' import SidebarTabTemplate from './SidebarTabTemplate.vue' import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue' -import { TaskItemImpl, useQueueStore } from '@/stores/queueStore' +import { + TaskItemDisplayStatus, + TaskItemImpl, + useQueueStore +} from '@/stores/queueStore' import { api } from '@/scripts/api' import { ComfyNode } from '@/types/comfyWorkflow' import { useSettingStore } from '@/stores/settingStore' @@ -170,9 +174,7 @@ const allTasks = computed(() => ? folderTask.value ? folderTask.value.flatten() : [] - : isExpanded.value - ? queueStore.flatTasks - : queueStore.tasks + : filterTasks(isExpanded.value ? queueStore.flatTasks : queueStore.tasks) ) const allGalleryItems = computed(() => allTasks.value.flatMap((task: TaskItemImpl) => { @@ -182,30 +184,24 @@ const allGalleryItems = computed(() => ) const filterTasks = (tasks: TaskItemImpl[]) => - tasks - .filter((t) => { - if ( - hideCanceled.value && - t.status?.messages?.at(-1)?.[0] === 'execution_interrupted' - ) { - return false - } + tasks.filter((task: TaskItemImpl) => { + if ( + hideCanceled.value && + task.displayStatus === TaskItemDisplayStatus.Cancelled + ) { + return false + } - if ( - hideCached.value && - t.flatOutputs?.length && - t.flatOutputs.every((o) => o.cached) - ) { - return false - } + if (hideCached.value && task.isCached) { + return false + } - return true - }) - .slice(0, ITEMS_PER_PAGE) + return true + }) const loadMoreItems = () => { const currentLength = visibleTasks.value.length - const newTasks = filterTasks(allTasks.value).slice( + const newTasks = allTasks.value.slice( currentLength, currentLength + ITEMS_PER_PAGE ) @@ -240,7 +236,7 @@ useResizeObserver(scrollContainer, () => { }) const updateVisibleTasks = () => { - visibleTasks.value = filterTasks(allTasks.value) + visibleTasks.value = allTasks.value } const toggleExpanded = () => { diff --git a/src/stores/queueStore.ts b/src/stores/queueStore.ts index 2c7f9240f..c37c9aa6a 100644 --- a/src/stores/queueStore.ts +++ b/src/stores/queueStore.ts @@ -265,6 +265,12 @@ export class TaskItemImpl { } } + get isCached() { + return ( + this.flatOutputs && _.every(this.flatOutputs, (output) => output.cached) + ) + } + get executionStartTimestamp() { const message = this.messages.find( (message) => message[0] === 'execution_start'