Skip to content
Snippets Groups Projects
Unverified Commit 66ca6fe7 authored by Chris Willis-Ford's avatar Chris Willis-Ford Committed by GitHub
Browse files

Merge pull request #1725 from cwillisf/fix-handle-extension-added

Fix handleExtensionAdded when no targets present
parents 6928da96 abf33be2
No related branches found
No related tags found
No related merge requests found
......@@ -221,11 +221,18 @@ class Blocks extends React.Component {
}
}
handleExtensionAdded (blocksInfo) {
this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json));
const dynamicBlocksXML = this.props.vm.runtime.getBlocksXML();
const target = this.props.vm.editingTarget;
const toolboxXML = makeToolboxXML(target.isStage, target.id, dynamicBlocksXML);
this.props.updateToolboxState(toolboxXML);
// select JSON from each block info object then reject the pseudo-blocks which don't have JSON, like separators
// this actually defines blocks and MUST run regardless of the UI state
this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json).filter(x => x));
// update the toolbox view: this can be skipped if we're not looking at a target, etc.
const runtime = this.props.vm.runtime;
const target = runtime.getEditingTarget() || runtime.getTargetForStage();
if (target) {
const dynamicBlocksXML = runtime.getBlocksXML();
const toolboxXML = makeToolboxXML(target.isStage, target.id, dynamicBlocksXML);
this.props.updateToolboxState(toolboxXML);
}
}
handleBlocksInfoUpdate (blocksInfo) {
// @todo Later we should replace this to avoid all the warnings from redefining blocks.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment