diff options
Diffstat (limited to 'src/content/actions/setting.ts')
-rw-r--r-- | src/content/actions/setting.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/content/actions/setting.ts b/src/content/actions/setting.ts new file mode 100644 index 0000000..92f8559 --- /dev/null +++ b/src/content/actions/setting.ts @@ -0,0 +1,28 @@ +import * as actions from './index'; +import * as operations from '../../shared/operations'; +import * as messages from '../../shared/messages'; +import Settings, { Keymaps } from '../../shared/Settings'; + +const reservedKeymaps: Keymaps = { + '<Esc>': { type: operations.CANCEL }, + '<C-[>': { type: operations.CANCEL }, +}; + +const set = (settings: Settings): actions.SettingAction => { + return { + type: actions.SETTING_SET, + settings: { + ...settings, + keymaps: { ...settings.keymaps, ...reservedKeymaps }, + } + }; +}; + +const load = async(): Promise<actions.SettingAction> => { + let settings = await browser.runtime.sendMessage({ + type: messages.SETTINGS_QUERY, + }); + return set(settings); +}; + +export { set, load }; |