From d1e5781c24276618c13588352964d0b440060460 Mon Sep 17 00:00:00 2001 From: Paul Rosset Date: Fri, 1 Dec 2017 19:03:04 +0000 Subject: [PATCH] Correction UiTab --- browser/main/StatusBar/index.js | 2 +- .../main/modals/PreferencesModal/HotkeyTab.js | 6 +++--- browser/main/modals/PreferencesModal/UiTab.js | 16 +++++++--------- browser/main/modals/PreferencesModal/index.js | 6 ++---- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/browser/main/StatusBar/index.js b/browser/main/StatusBar/index.js index 2106a230..49c1b40c 100644 --- a/browser/main/StatusBar/index.js +++ b/browser/main/StatusBar/index.js @@ -63,7 +63,7 @@ class StatusBar extends React.Component { {status.updateReady ? + : null } diff --git a/browser/main/modals/PreferencesModal/HotkeyTab.js b/browser/main/modals/PreferencesModal/HotkeyTab.js index cfd45d96..586faf04 100644 --- a/browser/main/modals/PreferencesModal/HotkeyTab.js +++ b/browser/main/modals/PreferencesModal/HotkeyTab.js @@ -79,9 +79,9 @@ class HotkeyTab extends React.Component { this.props.haveToSave(null) } else { this.props.haveToSave({ - tab: "Hotkey", - type: 'warning', - message: 'You have to save!' + tab: 'Hotkey', + type: 'warning', + message: 'You have to save!' }) } } diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 79314608..dcb9f6bc 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -38,16 +38,12 @@ class UiTab extends React.Component { message: err.message != null ? err.message : 'Error occurs!' }}) } - if (JSON.parse(localStorage.getItem('config'))) { - const {ui, editor, preview} = JSON.parse(localStorage.getItem('config')) - this.currentConfig = {ui, editor, preview} - } ipc.addListener('APP_SETTING_DONE', this.handleSettingDone) ipc.addListener('APP_SETTING_ERROR', this.handleSettingError) } componentWillMount () { - CodeMirror.autoLoadMode(ReactCodeMirror, 'javascript') + CodeMirror.autoLoadMode(ReactCodeMirror, 'javascript') } componentWillUnmount () { @@ -96,18 +92,20 @@ class UiTab extends React.Component { if (newCodemirrorTheme !== codemirrorTheme) { checkHighLight.setAttribute('href', `../node_modules/codemirror/theme/${newCodemirrorTheme.split(' ')[0]}.css`) } - - this.setState({ config: newConfig, codemirrorTheme: newCodemirrorTheme }, - () => { + this.setState({ config: newConfig, codemirrorTheme: newCodemirrorTheme }, () => { + if (JSON.parse(localStorage.getItem('config'))) { + const {ui, editor, preview} = JSON.parse(localStorage.getItem('config')) + this.currentConfig = {ui, editor, preview} if (JSON.stringify(this.currentConfig) === JSON.stringify(this.state.config)) { this.props.haveToSave(null) } else { this.props.haveToSave({ - tab: "UI", + tab: 'UI', type: 'warning', message: 'You have to save!' }) } + } }) } diff --git a/browser/main/modals/PreferencesModal/index.js b/browser/main/modals/PreferencesModal/index.js index f478f913..adf1e0d4 100644 --- a/browser/main/modals/PreferencesModal/index.js +++ b/browser/main/modals/PreferencesModal/index.js @@ -111,7 +111,7 @@ class Preferences extends React.Component { const navButtons = tabs.map((tab) => { const isActive = this.state.currentTab === tab.target - const isOk = typeof tab[tab.label] !== "undefined" && tab[tab.label] !== null + const isOk = typeof tab[tab.label] !== 'undefined' && tab[tab.label] !== null return ( ) })