Initialize default settings on background
This commit is contained in:
parent
e97ffafea3
commit
e3f95f9ecf
4 changed files with 57 additions and 59 deletions
39
src/background/default-settings.js
Normal file
39
src/background/default-settings.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
export default `{
|
||||
"keymaps": {
|
||||
"0": { "type": "scroll.home" },
|
||||
":": { "type": "command.show" },
|
||||
"o": { "type": "command.show.open", "alter": false },
|
||||
"O": { "type": "command.show.open", "alter": true },
|
||||
"t": { "type": "command.show.tabopen", "alter": false },
|
||||
"T": { "type": "command.show.tabopen", "alter": true },
|
||||
"b": { "type": "command.show.buffer" },
|
||||
"k": { "type": "scroll.lines", "count": -1 },
|
||||
"j": { "type": "scroll.lines", "count": 1 },
|
||||
"<C-E>": { "type": "scroll.lines", "count": -1 },
|
||||
"<C-Y>": { "type": "scroll.lines", "count": 1 },
|
||||
"<C-U>": { "type": "scroll.pages", "count": -0.5 },
|
||||
"<C-D>": { "type": "scroll.pages", "count": 0.5 },
|
||||
"<C-B>": { "type": "scroll.pages", "count": -1 },
|
||||
"<C-F>": { "type": "scroll.pages", "count": 1 },
|
||||
"gg": { "type": "scroll.top" },
|
||||
"G": { "type": "scroll.bottom" },
|
||||
"$": { "type": "scroll.end" },
|
||||
"d": { "type": "tabs.close" },
|
||||
"u": { "type": "tabs.reopen" },
|
||||
"h": { "type": "tabs.prev", "count": 1 },
|
||||
"l": { "type": "tabs.next", "count": 1 },
|
||||
"r": { "type": "tabs.reload", "cache": false },
|
||||
"R": { "type": "tabs.reload", "cache": true },
|
||||
"zi": { "type": "zoom.in" },
|
||||
"zo": { "type": "zoom.out" },
|
||||
"zz": { "type": "zoom.neutral" },
|
||||
"f": { "type": "follow.start", "newTab": false },
|
||||
"F": { "type": "follow.start", "newTab": true },
|
||||
"H": { "type": "navigate.history.prev" },
|
||||
"L": { "type": "navigate.history.next" },
|
||||
"[[": { "type": "navigate.link.prev" },
|
||||
"]]": { "type": "navigate.link.next" },
|
||||
"gu": { "type": "navigate.parent" },
|
||||
"gU": { "type": "navigate.root" }
|
||||
}
|
||||
}`;
|
|
@ -6,7 +6,7 @@ import * as consoleActions from '../actions/console';
|
|||
import * as tabActions from '../actions/tab';
|
||||
import reducers from '../reducers';
|
||||
import messages from '../messages';
|
||||
import DefaultSettings from '../settings/default-settings';
|
||||
import DefaultSettings from './default-settings';
|
||||
import * as store from '../store';
|
||||
|
||||
let prevInput = [];
|
||||
|
@ -92,10 +92,15 @@ browser.runtime.onMessage.addListener((message, sender) => {
|
|||
const initializeSettings = () => {
|
||||
browser.storage.local.get('settings').then((value) => {
|
||||
let settings = {};
|
||||
if (value.settings.json) {
|
||||
if (value.settings && value.settings.json) {
|
||||
settings = JSON.parse(value.settings.json);
|
||||
} else {
|
||||
settings = DefaultSettings;
|
||||
browser.storage.local.set({
|
||||
settings: {
|
||||
json: DefaultSettings
|
||||
}
|
||||
});
|
||||
}
|
||||
let action = inputActions.setKeymaps(settings.keymaps);
|
||||
backgroundStore.dispatch(action);
|
||||
|
|
Reference in a new issue