aboutsummaryrefslogtreecommitdiff
path: root/src/content/actions
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-11 08:04:01 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-11 08:04:01 +0900
commitbacf83a32083c5a4c4a45c061288081423bbf18a (patch)
treef5a73e2b989428ca3f3466b6e4a4cc744e24f4b7 /src/content/actions
parente76ca380f733b515c31297a285d8bea44e074a1b (diff)
Make settings as a clean architecture
Diffstat (limited to 'src/content/actions')
-rw-r--r--src/content/actions/index.ts11
-rw-r--r--src/content/actions/operation.ts7
-rw-r--r--src/content/actions/setting.ts28
3 files changed, 5 insertions, 41 deletions
diff --git a/src/content/actions/index.ts b/src/content/actions/index.ts
index 74353fb..4e395c5 100644
--- a/src/content/actions/index.ts
+++ b/src/content/actions/index.ts
@@ -1,13 +1,9 @@
import Redux from 'redux';
-import Settings from '../../shared/Settings';
import * as keyUtils from '../../shared/utils/keys';
// Find
export const FIND_SET_KEYWORD = 'find.set.keyword';
-// Settings
-export const SETTING_SET = 'setting.set';
-
// User input
export const INPUT_KEY_PRESS = 'input.key.press';
export const INPUT_CLEAR_KEYS = 'input.clear.keys';
@@ -37,11 +33,6 @@ export interface FindSetKeywordAction extends Redux.Action {
found: boolean;
}
-export interface SettingSetAction extends Redux.Action {
- type: typeof SETTING_SET;
- settings: Settings,
-}
-
export interface InputKeyPressAction extends Redux.Action {
type: typeof INPUT_KEY_PRESS;
key: keyUtils.Key;
@@ -94,7 +85,6 @@ export interface NoopAction extends Redux.Action {
}
export type FindAction = FindSetKeywordAction | NoopAction;
-export type SettingAction = SettingSetAction;
export type InputAction = InputKeyPressAction | InputClearKeysAction;
export type FollowAction =
FollowControllerEnableAction | FollowControllerDisableAction |
@@ -105,7 +95,6 @@ export type MarkAction =
export type Action =
FindAction |
- SettingAction |
InputAction |
FollowAction |
MarkAction |
diff --git a/src/content/actions/operation.ts b/src/content/actions/operation.ts
index 949f69f..f65d0bd 100644
--- a/src/content/actions/operation.ts
+++ b/src/content/actions/operation.ts
@@ -9,14 +9,16 @@ import * as consoleFrames from '../console-frames';
import * as markActions from './mark';
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
+import { SettingRepositoryImpl } from '../repositories/SettingRepository';
let addonEnabledUseCase = new AddonEnabledUseCase();
+let settingRepository = new SettingRepositoryImpl();
// eslint-disable-next-line complexity, max-lines-per-function
const exec = async(
operation: operations.Operation,
- settings: any,
): Promise<actions.Action> => {
+ let settings = settingRepository.get();
let smoothscroll = settings.properties.smoothscroll;
switch (operation.type) {
case operations.ADDON_ENABLE:
@@ -97,7 +99,8 @@ const exec = async(
break;
case operations.URLS_PASTE:
urls.paste(
- window, operation.newTab ? operation.newTab : false, settings.search
+ window, operation.newTab ? operation.newTab : false,
+ settings.search,
);
break;
default:
diff --git a/src/content/actions/setting.ts b/src/content/actions/setting.ts
deleted file mode 100644
index 92f8559..0000000
--- a/src/content/actions/setting.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-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 };