diff --git a/webmaker/src/components/Settings.jsx b/webmaker/src/components/Settings.jsx index b2e1c56..5a9eeab 100644 --- a/webmaker/src/components/Settings.jsx +++ b/webmaker/src/components/Settings.jsx @@ -1,10 +1,37 @@ import { h, Component } from 'preact'; import { editorThemes } from '../editorThemes'; +function CheckboxSetting({ + title, + label, + onChange, + pref, + name, + showWhenExtension +}) { + return ( + + ); +} export default class Settings extends Component { updateSetting(e) { this.props.onChange(e); } + shouldComponentUpdate() { + // TODO: add check on prefs + return true; + } render() { return (
@@ -18,9 +45,9 @@ export default class Settings extends Component {
- - - - - - - - - + label="Fast/light version" + pref={this.props.prefs.lightVersion} + onChange={this.updateSetting.bind(this)} + />
@@ -278,17 +277,13 @@ export default class Settings extends Component {

Fun

- + label="Code blast!" + name="isCodeBlastOn" + pref={this.props.prefs.isCodeBlastOn} + onChange={this.updateSetting.bind(this)} + />


@@ -302,6 +297,7 @@ export default class Settings extends Component { Maximum time allowed in a loop iteration {' '} diff --git a/webmaker/src/components/app.jsx b/webmaker/src/components/app.jsx index d4b4c04..2a48e5e 100644 --- a/webmaker/src/components/app.jsx +++ b/webmaker/src/components/app.jsx @@ -394,9 +394,10 @@ export default class App extends Component { var obj = {}; var el = e.target; log(settingName, el.type === 'checkbox' ? el.checked : el.value); - this.state.prefs[settingName] = - el.type === 'checkbox' ? el.checked : el.value; - obj[settingName] = this.state.prefs[settingName]; + const prefs = { ...this.state.prefs }; + prefs[settingName] = el.type === 'checkbox' ? el.checked : el.value; + obj[settingName] = prefs[settingName]; + this.setState({ prefs }); // We always save locally so that it gets fetched // faster on future loads. @@ -426,9 +427,6 @@ export default class App extends Component { this.contentWrap.applyCodemirrorSettings(this.state.prefs); - // Update indentation count when slider is updated - // indentationSizeValueEl.textContent = $('[data-setting=indentSize]').value; - /* scope.consoleCm.setOption('theme', $('[data-setting=editorTheme]').value); scope.acssSettingsCm.setOption(