1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

override default values to undefined attributes of config

This commit is contained in:
Dick Choi
2016-09-10 15:37:30 +09:00
parent f50968f992
commit 26f05b343e
2 changed files with 6 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ class TopBar extends React.Component {
this.createNote('SNIPPET_NOTE') this.createNote('SNIPPET_NOTE')
break break
case 'ALWAYS_ASK': case 'ALWAYS_ASK':
default:
let { dispatch, location } = this.props let { dispatch, location } = this.props
let { storage, folder } = this.resolveTargetFolder() let { storage, folder } = this.resolveTargetFolder()
@@ -181,7 +182,7 @@ class TopBar extends React.Component {
{ {
type: 'radio', type: 'radio',
label: 'Markdown Note', label: 'Markdown Note',
checked: config .ui.defaultNote === 'MARKDOWN_NOTE', checked: config.ui.defaultNote === 'MARKDOWN_NOTE',
click: (e) => this.setDefaultNote('MARKDOWN_NOTE') click: (e) => this.setDefaultNote('MARKDOWN_NOTE')
}, },
{ {

View File

@@ -53,6 +53,10 @@ function get () {
try { try {
config = Object.assign({}, defaultConfig, JSON.parse(config)) config = Object.assign({}, defaultConfig, JSON.parse(config))
config.hotkey = Object.assign({}, defaultConfig.hotkey, config.hotkey)
config.ui = Object.assign({}, defaultConfig.ui, config.ui)
config.editor = Object.assign({}, defaultConfig.editor, config.editor)
config.preview = Object.assign({}, defaultConfig.preview, config.preview)
if (!validate(config)) throw new Error('INVALID CONFIG') if (!validate(config)) throw new Error('INVALID CONFIG')
} catch (err) { } catch (err) {
console.warn('Boostnote resets the malformed configuration.') console.warn('Boostnote resets the malformed configuration.')