mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Fix Saving Configuration Bug
This commit is contained in:
@@ -149,10 +149,11 @@ class Main extends React.Component {
|
||||
const { dispatch, config } = this.props
|
||||
|
||||
this.refreshTheme = setInterval(() => {
|
||||
chooseTheme(ConfigManager.get().ui)
|
||||
const conf = ConfigManager.get()
|
||||
chooseTheme(conf)
|
||||
}, 5 * 1000)
|
||||
|
||||
chooseTheme(config.ui)
|
||||
chooseTheme(config)
|
||||
applyTheme(config.ui.theme)
|
||||
|
||||
if (getLocales().indexOf(config.ui.language) !== -1) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import _ from 'lodash'
|
||||
import RcParser from 'browser/lib/RcParser'
|
||||
import i18n from 'browser/lib/i18n'
|
||||
import ee from 'browser/main/lib/eventEmitter'
|
||||
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
||||
|
||||
const OSX = global.process.platform === 'darwin'
|
||||
const win = global.process.platform === 'win32'
|
||||
@@ -204,9 +203,6 @@ function set(updates) {
|
||||
if (!validate(newConfig)) throw new Error('INVALID CONFIG')
|
||||
_save(newConfig)
|
||||
|
||||
chooseTheme(newConfig.ui)
|
||||
applyTheme(newConfig.ui.theme)
|
||||
|
||||
i18n.setLocale(newConfig.ui.language)
|
||||
|
||||
let editorTheme = document.getElementById('editorTheme')
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
const chooseTheme = ui => {
|
||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||
|
||||
const saveChanges = newConfig => {
|
||||
ConfigManager.set(newConfig)
|
||||
}
|
||||
|
||||
const chooseTheme = config => {
|
||||
const { ui } = config
|
||||
if (!ui.enableScheduleTheme) {
|
||||
return
|
||||
}
|
||||
@@ -21,11 +28,13 @@ const chooseTheme = ui => {
|
||||
ui.defaultTheme = ui.theme
|
||||
ui.theme = ui.scheduledTheme
|
||||
applyTheme(ui.theme)
|
||||
saveChanges(config)
|
||||
}
|
||||
} else {
|
||||
if (ui.theme !== ui.defaultTheme) {
|
||||
ui.theme = ui.defaultTheme
|
||||
applyTheme(ui.theme)
|
||||
saveChanges(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +49,11 @@ const applyTheme = theme => {
|
||||
]
|
||||
if (supportedThemes.indexOf(theme) !== -1) {
|
||||
document.body.setAttribute('data-theme', theme)
|
||||
if (document.body.querySelector('.MarkdownPreview')) {
|
||||
document.body
|
||||
.querySelector('.MarkdownPreview')
|
||||
.contentDocument.body.setAttribute('data-theme', theme)
|
||||
}
|
||||
} else {
|
||||
document.body.setAttribute('data-theme', 'default')
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import i18n from 'browser/lib/i18n'
|
||||
import { getLanguages } from 'browser/lib/Languages'
|
||||
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
|
||||
import uiThemes from 'browser/lib/ui-themes'
|
||||
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
||||
|
||||
const OSX = global.process.platform === 'darwin'
|
||||
|
||||
@@ -194,6 +195,9 @@ class UiTab extends React.Component {
|
||||
preview: this.state.config.preview
|
||||
}
|
||||
|
||||
chooseTheme(newConfig)
|
||||
applyTheme(newConfig.ui.theme)
|
||||
|
||||
ConfigManager.set(newConfig)
|
||||
|
||||
store.dispatch({
|
||||
|
||||
Reference in New Issue
Block a user