From 387524a407be74c3d52758c2b98ef1f93c4289da Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Fri, 3 Nov 2017 14:54:13 +0900 Subject: [PATCH] fix plugin load --- .eslintrc | 1 + src/content/components/common/index.js | 4 ++++ src/content/reducers/setting.js | 4 +++- test/content/reducers/setting.test.js | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9820e69..949b5a5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -35,6 +35,7 @@ "multiline-ternary": "off", "newline-after-var": "off", "newline-before-return": "off", + "newline-per-chained-call": "off", "no-bitwise": "off", "no-console": ["error", { "allow": ["warn", "error"] }], "no-empty-function": "off", diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js index 4c2c1df..565632c 100644 --- a/src/content/components/common/index.js +++ b/src/content/components/common/index.js @@ -32,6 +32,10 @@ export default class Common { type: messages.SETTINGS_QUERY, }).then((settings) => { this.store.dispatch(settingActions.set(settings)); + }).catch((e) => { + // Sometime sendMessage fails when background script is not ready. + console.warn(e); + setTimeout(() => this.reloadSettings(), 500); }); } } diff --git a/src/content/reducers/setting.js b/src/content/reducers/setting.js index 22fac6f..b6f6c58 100644 --- a/src/content/reducers/setting.js +++ b/src/content/reducers/setting.js @@ -1,6 +1,8 @@ import actions from 'content/actions'; -const defaultState = {}; +const defaultState = { + keymaps: {}, +}; export default function reducer(state = defaultState, action = {}) { switch (action.type) { diff --git a/test/content/reducers/setting.test.js b/test/content/reducers/setting.test.js index 50d1cf0..ef49594 100644 --- a/test/content/reducers/setting.test.js +++ b/test/content/reducers/setting.test.js @@ -5,7 +5,7 @@ import settingReducer from 'content/reducers/setting'; describe("content setting reducer", () => { it('return the initial state', () => { let state = settingReducer(undefined, {}); - expect(state).to.deep.equal({}); + expect(state).to.deep.equal({ keymaps: {} }); }); it('return next state for SETTING_SET', () => {