Fixing no-category toolboxes so they populate immediately, rather (#1255)

than on a timeout.
This commit is contained in:
CoryDCode
2017-08-16 16:05:35 -07:00
committed by GitHub
parent 859d63633e
commit 29582ba0d7

View File

@@ -90,24 +90,20 @@ blocklyApp.ToolboxModalService = ng.core.Class({
);
this.computeCategoriesForCreateNewGroupModal_();
} else {
// A timeout seems to be needed in order for the .children accessor to
// work correctly.
var that = this;
setTimeout(function() {
// If there are no top-level categories, we create a single category
// containing all the top-level blocks.
var tmpWorkspace = new Blockly.Workspace();
Array.from(toolboxXmlElt.children).forEach(function(topLevelNode) {
Blockly.Xml.domToBlock(tmpWorkspace, topLevelNode);
});
that.allToolboxCategories = [{
categoryName: '',
blocks: tmpWorkspace.topBlocks_
}];
that.computeCategoriesForCreateNewGroupModal_();
// If there are no top-level categories, we create a single category
// containing all the top-level blocks.
var tmpWorkspace = new Blockly.Workspace();
Array.from(toolboxXmlElt.children).forEach(function(topLevelNode) {
Blockly.Xml.domToBlock(tmpWorkspace, topLevelNode);
});
that.allToolboxCategories = [{
categoryName: '',
blocks: tmpWorkspace.topBlocks_
}];
that.computeCategoriesForCreateNewGroupModal_();
}
},
computeCategoriesForCreateNewGroupModal_: function() {