Line data Source code
1 : import type { CreateAssetExportData } from '@comfyorg/ingest-types'
2 : import { useI18n } from 'vue-i18n'
3 :
4 : import { useToast } from '@/components/ui/toast/toastStore'
5 : import { assetService } from '@/platform/assets/services/assetService'
6 : import { reportError } from '@comfyorg/telemetry/reportError'
7 : import { useAssetExportStore } from '@/stores/assetExportStore'
8 :
9 5269 : export function useAssetZipExport() {
10 5269 : const { t } = useI18n()
11 5269 : const toast = useToast()
12 :
13 0 : async function startZipExport(
14 : request: CreateAssetExportData['body'],
15 : fileCount: number
16 : ): Promise<void> {
17 0 : try {
18 0 : const { task_id } = await assetService.createAssetExport(request)
19 0 : useAssetExportStore().trackExport(task_id)
20 0 : toast.info(t('exportToast.exportStarted'), {
21 : description: t(
22 : 'mediaAsset.selection.exportStarted',
23 : { count: fileCount },
24 : fileCount
25 : ),
26 : duration: 3000
27 : })
28 : } catch (error) {
29 0 : reportError(error, {
30 : errorType: 'error_exporting_assets',
31 : surface: 'assets',
32 : context: { count: fileCount }
33 : })
34 0 : toast.error(t('g.error'), {
35 : description: t('exportToast.exportFailedSingle')
36 : })
37 : }
38 : }
39 :
40 5269 : return { startZipExport }
41 : }
|