aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
Diffstat (limited to 'src/background')
-rw-r--r--src/background/actions/index.js4
-rw-r--r--src/background/actions/setting.js13
-rw-r--r--src/background/components/background.js4
-rw-r--r--src/background/index.js4
-rw-r--r--src/background/reducers/index.js2
-rw-r--r--src/background/reducers/setting.js17
6 files changed, 39 insertions, 5 deletions
diff --git a/src/background/actions/index.js b/src/background/actions/index.js
new file mode 100644
index 0000000..8c212c2
--- /dev/null
+++ b/src/background/actions/index.js
@@ -0,0 +1,4 @@
+export default {
+ // Settings
+ SETTING_SET_SETTINGS: 'setting.set.settings',
+};
diff --git a/src/background/actions/setting.js b/src/background/actions/setting.js
new file mode 100644
index 0000000..0454a68
--- /dev/null
+++ b/src/background/actions/setting.js
@@ -0,0 +1,13 @@
+import actions from '../actions';
+import * as settingsStorage from 'shared/settings/storage';
+
+const load = () => {
+ return settingsStorage.loadValue().then((value) => {
+ return {
+ type: actions.SETTING_SET_SETTINGS,
+ value,
+ };
+ });
+};
+
+export { load };
diff --git a/src/background/components/background.js b/src/background/components/background.js
index 2d94310..22c6693 100644
--- a/src/background/components/background.js
+++ b/src/background/components/background.js
@@ -1,6 +1,6 @@
import messages from 'shared/messages';
import * as operationActions from 'background/actions/operation';
-import * as settingsActions from 'settings/actions/setting';
+import * as settingActions from 'background/actions/setting';
import * as tabActions from 'background/actions/tab';
import * as commands from 'shared/commands';
@@ -46,7 +46,7 @@ export default class BackgroundComponent {
case messages.CONSOLE_QUERY_COMPLETIONS:
return commands.complete(message.text, settings.value);
case messages.SETTINGS_RELOAD:
- this.store.dispatch(settingsActions.load());
+ this.store.dispatch(settingActions.load());
return this.broadcastSettingsChanged();
}
}
diff --git a/src/background/index.js b/src/background/index.js
index 8a68767..3ef712f 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -1,4 +1,4 @@
-import * as settingsActions from 'settings/actions/setting';
+import * as settingActions from 'background/actions/setting';
import messages from 'shared/messages';
import BackgroundComponent from 'background/components/background';
import reducers from 'background/reducers';
@@ -16,4 +16,4 @@ const store = createStore(reducers, (e, sender) => {
// eslint-disable-next-line no-unused-vars
const backgroundComponent = new BackgroundComponent(store);
-store.dispatch(settingsActions.load());
+store.dispatch(settingActions.load());
diff --git a/src/background/reducers/index.js b/src/background/reducers/index.js
index 4be8fac..dab0c62 100644
--- a/src/background/reducers/index.js
+++ b/src/background/reducers/index.js
@@ -1,4 +1,4 @@
-import settingReducer from 'settings/reducers/setting';
+import settingReducer from './setting';
// Make setting reducer instead of re-use
const defaultState = {
diff --git a/src/background/reducers/setting.js b/src/background/reducers/setting.js
new file mode 100644
index 0000000..70bf8ea
--- /dev/null
+++ b/src/background/reducers/setting.js
@@ -0,0 +1,17 @@
+import actions from 'settings/actions';
+
+const defaultState = {
+ value: {},
+};
+
+export default function reducer(state = defaultState, action = {}) {
+ switch (action.type) {
+ case actions.SETTING_SET_SETTINGS:
+ return {
+ value: action.value,
+ };
+ default:
+ return state;
+ }
+}
+