From d835ffc449058887d5051745af70a5d6dc3db666 Mon Sep 17 00:00:00 2001 From: Mario Pesch Date: Wed, 24 Mar 2021 17:05:21 +0100 Subject: [PATCH] fix load projects --- src/components/Blockly/BlocklyWindow.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index 7a807a9..dd930fa 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -21,17 +21,17 @@ class BlocklyWindow extends Component { } componentDidMount() { - console.log(this.props); const workspace = Blockly.getMainWorkspace(); - - if (this.props.workspaceXML !== "") { - Blockly.Xml.clearWorkspaceAndLoadFromXml( - Blockly.Xml.textToDom(this.props.workspaceXML), - workspace - ); - } else { - this.props.onChangeWorkspace({}); - this.props.clearStats(); + if (!this.props.initialXml) { + if (this.props.workspaceXML !== "") { + Blockly.Xml.clearWorkspaceAndLoadFromXml( + Blockly.Xml.textToDom(this.props.workspaceXML), + workspace + ); + } else { + this.props.onChangeWorkspace({}); + this.props.clearStats(); + } } workspace.addChangeListener((event) => { this.props.onChangeWorkspace(event); @@ -47,8 +47,6 @@ class BlocklyWindow extends Component { componentDidUpdate(props) { const workspace = Blockly.getMainWorkspace(); var xml = this.props.initialXml; - console.log(xml) - console.log(this.props.xml) // if svg is true, then the update process is done in the BlocklySvg component if (props.initialXml !== xml && !this.props.svg) { // guarantees that the current xml-code (this.props.initialXml) is rendered