diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js index ddec6e3..f932ce8 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js @@ -366,11 +366,15 @@ export default function getProxyEditor(theState) { super(props); this.state = getInitState(); + this.resetState = linkEvent(this, this.resetState); } resetState(that, event) { + if (that.state.ifHasErrors) { + that.props.funs.setStatusTo(''); // Clear errors + } that.setState(getInitState()); event.preventDefault(); @@ -417,28 +421,32 @@ export default function getProxyEditor(theState) { handleModeSwitch(that, event) { - if (that.state.stashedExports !== false) { - const errors = that.getErrorsInStashedExports(); - if (errors) { - that.setState({ifHasErrors: true}); - that.props.funs.showErrors(...errors); - return; - } - that.props.setProxyStringRaw(that.state.stashedExports); + console.log('SWITCH!'); + if (that.state.ifHasErrors) { + return; } - that.setState({ - stashedExports: false, - ifHasErrors: false, - }); that.props.onSwitch(); } handleTextareaChange(that, event) { + console.log('CHANGE!'); that.setState({ stashedExports: normalizeProxyString(event.target.value), }); + const errors = that.getErrorsInStashedExports(); + if (errors) { + that.setState({ifHasErrors: true}); + that.props.funs.showErrors(...errors); + return; + } + // No errors. + that.props.setProxyStringRaw(that.state.stashedExports); + that.setState({ + stashedExports: false, + ifHasErrors: false, + }); } @@ -451,8 +459,6 @@ export default function getProxyEditor(theState) { render(props) { - const reset = linkEvent(this, this.resetState); - return (