diff --git a/ext/src/options/index.jsx b/ext/src/options/index.jsx index 23f6b7c..57f893c 100644 --- a/ext/src/options/index.jsx +++ b/ext/src/options/index.jsx @@ -44,7 +44,8 @@ class App extends Component { super(props); this.state = { - options: props.options + hasLoaded: false + , options: null , bridgeInfo: null , platform: null , bridgeLoading: true @@ -63,13 +64,21 @@ class App extends Component { } async componentDidMount () { + const { options } = await browser.storage.sync.get("options"); + + this.setState({ + hasLoaded: true + , options + }); + const bridgeInfo = await getBridgeInfo(); const platform = await browser.runtime.getPlatformInfo(); + this.setState({ bridgeInfo , platform: platform.os , bridgeLoading: false - }); + }) } /** @@ -83,11 +92,8 @@ class App extends Component { handleReset () { this.setState({ - options: defaultOptions + options: { ...defaultOptions } }); - - // TODO: Propagate state properly - this.form.submit(); } async handleFormSubmit (ev) { @@ -128,7 +134,9 @@ class App extends Component { } catch (err) {} } - handleFormChange () { + handleFormChange (ev) { + ev.preventDefault(); + this.setState({ isFormValid: this.form.checkValidity() }); @@ -168,6 +176,10 @@ class App extends Component { } render () { + if (!this.state.hasLoaded) { + return; + } + return (
{ - const { options } = await browser.storage.sync.get("options"); - - ReactDOM.render( - - , document.querySelector("#root")); -})() +ReactDOM.render( + + , document.querySelector("#root")); diff --git a/ext/src/updater/index.jsx b/ext/src/updater/index.jsx index 037061a..1cd4d1e 100644 --- a/ext/src/updater/index.jsx +++ b/ext/src/updater/index.jsx @@ -197,17 +197,19 @@ class App extends Component { } render () { - return do { - if (this.state.hasLoaded) { - - } + if (!this.state.hasLoaded) { + return; } + + return ( + + ); } }