11import { ref , shallowRef } from 'vue'
22
33import type { JobListItem } from '@/composables/queue/useJobList'
4- import type { ResultItemImpl , TaskItemImpl } from '@/stores/queueStore'
4+ import type { ResultItemImpl } from '@/stores/queueStore'
55
66type FetchApi = ( url : string ) => Promise < Response >
77
8+ /**
9+ * Minimal interface for tasks used by the result gallery.
10+ * This allows the gallery to work with any object that provides these properties,
11+ * without coupling to the full TaskItemImpl class.
12+ */
13+ interface GalleryTask {
14+ readonly promptId : string
15+ readonly outputsCount ?: number
16+ readonly flatOutputs : readonly ResultItemImpl [ ]
17+ readonly previewOutput ?: ResultItemImpl
18+ loadFullOutputs ( fetchApi : FetchApi ) : Promise < GalleryTask >
19+ }
20+
821const getPreviewableOutputs = ( outputs ?: readonly ResultItemImpl [ ] ) =>
922 outputs ?. filter ( ( o ) => o . supportsPreview ) ?? [ ]
1023
@@ -18,17 +31,17 @@ const findActiveIndex = (items: ResultItemImpl[], url?: string): number => {
1831 * Manages result gallery state and activation for queue items.
1932 */
2033export function useResultGallery (
21- getFilteredTasks : ( ) => TaskItemImpl [ ] ,
34+ getFilteredTasks : ( ) => GalleryTask [ ] ,
2235 fetchApi ?: FetchApi
2336) {
2437 const galleryActiveIndex = ref ( - 1 )
2538 const galleryItems = shallowRef < ResultItemImpl [ ] > ( [ ] )
2639
27- const loadedTasksCache = new Map < string , TaskItemImpl > ( )
40+ const loadedTasksCache = new Map < string , GalleryTask > ( )
2841 let currentRequestId = 0
2942
3043 const getOutputsForTask = async (
31- task : TaskItemImpl
44+ task : GalleryTask
3245 ) : Promise < ResultItemImpl [ ] > => {
3346 const outputsCount = task . outputsCount ?? 0
3447 const needsLazyLoad = outputsCount > 1 && fetchApi
@@ -54,7 +67,7 @@ export function useResultGallery(
5467
5568 const requestId = ++ currentRequestId
5669
57- const targetTask = item . taskRef as TaskItemImpl | undefined
70+ const targetTask = item . taskRef as GalleryTask | undefined
5871 let targetOutputs : ResultItemImpl [ ] = [ ]
5972
6073 if ( targetTask ) {
0 commit comments