Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/jwunderl/no spurious error on asset driver #10193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions localtypings/pxteditor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pxtservices/iframeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!];

Expand Down
12 changes: 8 additions & 4 deletions webapp/src/assetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand All @@ -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;
}
Expand Down