Add a promise-based toast when exporting (#2541)

* Add loading and success toasts to export engine command

* Move doExport out to a test utility, test visibility of loading spinner

* Add playwright test for export success toast

* Update Cargo.lock

* Remove loading assertion, it flashes too quickly for Playwright to pick up
This commit is contained in:
Frank Noirot
2024-05-29 18:04:27 -04:00
committed by GitHub
parent 450afb1605
commit e6641e68f3
6 changed files with 276 additions and 149 deletions

View File

@ -994,6 +994,10 @@ export class EngineCommandManager {
engineConnection?: EngineConnection
defaultPlanes: DefaultPlanes | null = null
commandLogs: CommandLog[] = []
pendingExport?: {
resolve: (filename?: string) => void
reject: (reason: any) => void
}
_commandLogCallBack: (command: CommandLog[]) => void = () => {}
private resolveReady = () => {}
/** Folks should realize that wait for ready does not get called _everytime_
@ -1150,7 +1154,9 @@ export class EngineCommandManager {
// because in all other cases we send JSON strings. But in the case of
// export we send a binary blob.
// Pass this to our export function.
void exportSave(event.data)
exportSave(event.data).then(() => {
this.pendingExport?.resolve()
}, this.pendingExport?.reject)
} else {
const message: Models['WebSocketResponse_type'] = JSON.parse(
event.data
@ -1548,6 +1554,12 @@ export class EngineCommandManager {
this.outSequence++
this.engineConnection?.unreliableSend(command)
return Promise.resolve()
} else if (cmd.type === 'export') {
const promise = new Promise((resolve, reject) => {
this.pendingExport = { resolve, reject }
})
this.engineConnection?.send(command)
return promise
}
if (
command.cmd.type === 'default_camera_look_at' ||