load default settings
This commit is contained in:
parent
aecb4d9027
commit
7a85b203ac
3 changed files with 16 additions and 4 deletions
|
@ -1,9 +1,13 @@
|
||||||
import actions from '../actions';
|
import actions from '../actions';
|
||||||
import messages from '../content/messages';
|
import messages from '../content/messages';
|
||||||
|
import DefaultSettings from '../shared/default-settings';
|
||||||
|
|
||||||
const load = () => {
|
const load = () => {
|
||||||
return browser.storage.local.get('settings').then((value) => {
|
return browser.storage.local.get('settings').then((value) => {
|
||||||
return set(value.settings);
|
if (value.settings) {
|
||||||
|
return set(value.settings);
|
||||||
|
}
|
||||||
|
return set(DefaultSettings);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import * as consoleActions from '../actions/console';
|
||||||
import * as tabActions from '../actions/tab';
|
import * as tabActions from '../actions/tab';
|
||||||
import reducers from '../reducers';
|
import reducers from '../reducers';
|
||||||
import messages from '../content/messages';
|
import messages from '../content/messages';
|
||||||
|
import DefaultSettings from '../shared/default-settings';
|
||||||
import * as store from '../store';
|
import * as store from '../store';
|
||||||
|
|
||||||
let prevInput = [];
|
let prevInput = [];
|
||||||
|
@ -58,7 +59,12 @@ const keyQueueChanged = (state, sender) => {
|
||||||
|
|
||||||
const reloadSettings = () => {
|
const reloadSettings = () => {
|
||||||
browser.storage.local.get('settings').then((value) => {
|
browser.storage.local.get('settings').then((value) => {
|
||||||
let settings = JSON.parse(value.settings.json);
|
let settings = null;
|
||||||
|
if (value.settings) {
|
||||||
|
settings = JSON.parse(value.settings.json);
|
||||||
|
} else {
|
||||||
|
settings = JSON.parse(DefaultSettings.json);
|
||||||
|
}
|
||||||
let action = inputActions.setKeymaps(settings.keymaps);
|
let action = inputActions.setKeymaps(settings.keymaps);
|
||||||
backgroundStore.dispatch(action);
|
backgroundStore.dispatch(action);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export default `{
|
export default {
|
||||||
|
json: `{
|
||||||
"keymaps": {
|
"keymaps": {
|
||||||
"0": { "type": "scroll.home" },
|
"0": { "type": "scroll.home" },
|
||||||
":": { "type": "command.show" },
|
":": { "type": "command.show" },
|
||||||
|
@ -36,4 +37,5 @@ export default `{
|
||||||
"gu": { "type": "navigate.parent" },
|
"gu": { "type": "navigate.parent" },
|
||||||
"gU": { "type": "navigate.root" }
|
"gU": { "type": "navigate.root" }
|
||||||
}
|
}
|
||||||
}`;
|
}`
|
||||||
|
};
|
Reference in a new issue