Skip to content
Snippets Groups Projects
Commit 118cd456 authored by chrisgarrity's avatar chrisgarrity
Browse files

Only update blocks locale when blocks are visible

In `blocks.jsx` only call setLocale if visible. Depends on `getLocale` being added to VM to know when global locale changed while not visible making the VM out of sync.
parent ea14185f
No related branches found
No related tags found
No related merge requests found
...@@ -94,7 +94,9 @@ class Blocks extends React.Component { ...@@ -94,7 +94,9 @@ class Blocks extends React.Component {
addFunctionListener(this.workspace, 'zoom', this.onWorkspaceMetricsChange); addFunctionListener(this.workspace, 'zoom', this.onWorkspaceMetricsChange);
this.attachVM(); this.attachVM();
this.setLocale(); if (this.props.isVisible) {
this.setLocale();
}
analytics.pageview('/editors/blocks'); analytics.pageview('/editors/blocks');
} }
...@@ -117,9 +119,9 @@ class Blocks extends React.Component { ...@@ -117,9 +119,9 @@ class Blocks extends React.Component {
this.ScratchBlocks.hideChaff(); this.ScratchBlocks.hideChaff();
} }
if (prevProps.locale !== this.props.locale) { // if (prevProps.locale !== this.props.locale) {
this.setLocale(); // this.setLocale();
} // }
if (prevProps.toolboxXML !== this.props.toolboxXML) { if (prevProps.toolboxXML !== this.props.toolboxXML) {
// rather than update the toolbox "sync" -- update it in the next frame // rather than update the toolbox "sync" -- update it in the next frame
...@@ -138,10 +140,17 @@ class Blocks extends React.Component { ...@@ -138,10 +140,17 @@ class Blocks extends React.Component {
// @todo hack to resize blockly manually in case resize happened while hidden // @todo hack to resize blockly manually in case resize happened while hidden
// @todo hack to reload the workspace due to gui bug #413 // @todo hack to reload the workspace due to gui bug #413
if (this.props.isVisible) { // Scripts tab if (this.props.isVisible) { // Scripts tab
this.workspace.setVisible(true); this.workspace.setVisible(true);
this.props.vm.refreshWorkspace(); if (prevProps.locale !== this.props.locale || this.props.locale !== this.props.vm.getLocale()) {
this.setLocale();
} else {
this.props.vm.refreshWorkspace();
}
// Re-enable toolbox refreshes without causing one. See #updateToolbox for more info. // Re-enable toolbox refreshes without causing one. See #updateToolbox for more info.
this.workspace.toolboxRefreshEnabled_ = true; this.workspace.toolboxRefreshEnabled_ = true;
// this.workspace.setToolboxRefreshEnabled(true);
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));
} else { } else {
this.workspace.setVisible(false); this.workspace.setVisible(false);
......
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