Line data Source code
1 : import { useToast } from '@/components/ui/toast/toastStore'
2 : import { t } from '@/i18n'
3 :
4 : import type { LoadModelOutcome } from '@comfyorg/viewport3d/load3d/interfaces'
5 :
6 : /**
7 : * Warns the user about a failed model load. `silentOnNotFound` hides the
8 : * warning for a missing file that a preview surface may legitimately lack.
9 : */
10 19 : export function reportLoadModelOutcome(
11 : outcome: LoadModelOutcome,
12 : { silentOnNotFound = false }: { silentOnNotFound?: boolean } = {}
13 : ): void {
14 19 : if (outcome === 'unknown-type') {
15 0 : useToast().warning(t('toastMessages.couldNotDetermineFileType'))
16 0 : return
17 : }
18 19 : if (outcome === 'failed' || (outcome === 'not-found' && !silentOnNotFound)) {
19 1 : useToast().warning(t('toastMessages.errorLoadingModel'))
20 : }
21 : }
|