@@ -2,9 +2,7 @@ import { ref } from 'vue'
22
33import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
44import { assetService } from '@/platform/assets/services/assetService'
5- import type { HistoryTaskItem } from '@/schemas/apiSchema'
6- import { api } from '@/scripts/api'
7- import { TaskItemImpl } from '@/stores/queueStore'
5+ import { useQueueStore } from '@/stores/queueStore'
86import { truncateFilename } from '@/utils/formatUtil'
97
108import { mapTaskOutputToAssetItem } from './assetMappers'
@@ -43,41 +41,22 @@ export function useAssetsApi() {
4341 } ) )
4442 }
4543
46- // For output directory, fetch history data and convert to AssetItem format
47- const historyResponse = await api . getHistory ( 200 )
44+ // For output directory, use QueueStore's flatTasks
45+ const queueStore = useQueueStore ( )
4846
49- if ( ! historyResponse ?. History ) {
50- return [ ]
51- }
52-
53- // Convert history items to AssetItem format
54- const assetItems : AssetItem [ ] = [ ]
55-
56- historyResponse . History . forEach ( ( historyItem : HistoryTaskItem ) => {
57- // Create TaskItemImpl to use existing logic
58- const taskItem = new TaskItemImpl (
59- historyItem . taskType ,
60- historyItem . prompt ,
61- historyItem . status ,
62- historyItem . outputs
47+ // Get all flat tasks that have preview outputs
48+ const assetItems : AssetItem [ ] = queueStore . flatTasks
49+ . filter (
50+ ( task ) => task . previewOutput && task . displayStatus === 'Completed'
6351 )
64-
65- // Only process completed tasks
66- if ( taskItem . displayStatus === 'Completed' && taskItem . outputs ) {
67- // Process each output
68- taskItem . flatOutputs . forEach ( ( output ) => {
69- // Only include output type files (not temp previews)
70- if ( output . type === 'output' && output . supportsPreview ) {
71- const assetItem = mapTaskOutputToAssetItem (
72- taskItem ,
73- output ,
74- true // Use display name for cloud
75- )
76- assetItems . push ( assetItem )
77- }
78- } )
79- }
80- } )
52+ . map ( ( task ) => {
53+ const output = task . previewOutput !
54+ return mapTaskOutputToAssetItem (
55+ task ,
56+ output ,
57+ true // Use display name for cloud
58+ )
59+ } )
8160
8261 return assetItems
8362 } catch ( err ) {
0 commit comments