Bug fix: make dismiss during export not fire success toast (#3882)

* Bug fix: make dismiss during export not fire success toast

* Fix export fail test, since this failure errors early now

* Remove throttling from send side

* Move toast.loading out to when first engine command is sent, so it is shown immediately

* Use shared, named constants for toast messages

* Hook up a couple other error toasts to the `pendingExport.toastId`
This commit is contained in:
Frank Noirot
2024-09-17 19:06:06 -04:00
committed by GitHub
parent 62b78840b6
commit 00fa40bbc9
8 changed files with 117 additions and 69 deletions

View File

@ -415,20 +415,9 @@ export const ModelingMachineProvider = ({
selection: { type: 'default_scene' },
}
// Artificially delay the export in playwright tests
toast
.promise(
exportFromEngine({
format: format,
}),
{
loading: 'Starting print...',
success: 'Started print successfully',
error: 'Error while starting print',
}
)
.catch(reportRejection)
exportFromEngine({
format: format,
}).catch(reportRejection)
},
'Engine export': ({ event }) => {
if (event.type !== 'Export') return
@ -482,18 +471,9 @@ export const ModelingMachineProvider = ({
format.selection = { type: 'default_scene' }
}
toast
.promise(
exportFromEngine({
format: format as Models['OutputFormat_type'],
}),
{
loading: 'Exporting...',
success: 'Exported successfully',
error: 'Error while exporting',
}
)
.catch(reportRejection)
exportFromEngine({
format: format as Models['OutputFormat_type'],
}).catch(reportRejection)
},
'Submit to Text-to-CAD API': ({ event }) => {
if (event.type !== 'Text-to-CAD') return
@ -591,7 +571,9 @@ export const ModelingMachineProvider = ({
else if (kclManager.ast.body.length === 0)
errorMessage += 'due to Empty Scene'
console.error(errorMessage)
toast.error(errorMessage)
toast.error(errorMessage, {
id: kclManager.engineCommandManager.pendingExport?.toastId,
})
return false
}
},