diff --git a/localtypings/pxteditor.d.ts b/localtypings/pxteditor.d.ts index 7ba3c537a68e..e71924644bb8 100644 --- a/localtypings/pxteditor.d.ts +++ b/localtypings/pxteditor.d.ts @@ -1296,6 +1296,14 @@ declare namespace pxt.editor { interface BaseAssetEditorResponse { id?: number; + /** + * indicate if operation started or completed successfully + */ + success: boolean; + /** + * Error object if any + */ + error?: any; } interface OpenAssetEditorResponse extends BaseAssetEditorResponse { diff --git a/pxtservices/iframeDriver.ts b/pxtservices/iframeDriver.ts index bef798c45622..f4fe919d6d2f 100644 --- a/pxtservices/iframeDriver.ts +++ b/pxtservices/iframeDriver.ts @@ -98,9 +98,9 @@ export abstract class IframeDriver { } protected resolvePendingMessage(event: MessageEvent) { - const data = event.data as pxt.editor.EditorMessageResponse; - if (data.id && this.pendingMessages[data.id]) { - const resp = event.data as pxt.editor.EditorMessageResponse; + const resp = event.data as pxt.editor.EditorMessageResponse | pxt.editor.AssetEditorResponse; + + if (resp.id && this.pendingMessages[resp.id]) { const pending = this.pendingMessages[resp.id!]; delete this.pendingMessages[resp.id!]; diff --git a/webapp/src/assetEditor.tsx b/webapp/src/assetEditor.tsx index 6deb11e92326..e7b0d1fea35b 100644 --- a/webapp/src/assetEditor.tsx +++ b/webapp/src/assetEditor.tsx @@ -58,7 +58,8 @@ export class AssetEditor extends React.Component<{}, AssetEditorState> { this.sendResponse({ id: request.id, - type: request.type + type: request.type, + success: true }); break; case "open": @@ -73,7 +74,8 @@ export class AssetEditor extends React.Component<{}, AssetEditorState> { }); this.sendResponse({ id: request.id, - type: request.type + type: request.type, + success: true }); break; case "duplicate": @@ -85,14 +87,16 @@ export class AssetEditor extends React.Component<{}, AssetEditorState> { }); this.sendResponse({ id: request.id, - type: request.type + type: request.type, + success: true, }); break; case "save": this.sendResponse({ id: request.id, type: request.type, - files: this.saveProjectFiles() + files: this.saveProjectFiles(), + success: true }); break; }