Merge pull request #129 from ueokande/retry-setting-load

fix plugin load
jh-changes
Shin'ya Ueoka 7 years ago committed by GitHub
commit 516a701ebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc
  2. 4
      src/content/components/common/index.js
  3. 4
      src/content/reducers/setting.js
  4. 2
      test/content/reducers/setting.test.js

@ -35,6 +35,7 @@
"multiline-ternary": "off", "multiline-ternary": "off",
"newline-after-var": "off", "newline-after-var": "off",
"newline-before-return": "off", "newline-before-return": "off",
"newline-per-chained-call": "off",
"no-bitwise": "off", "no-bitwise": "off",
"no-console": ["error", { "allow": ["warn", "error"] }], "no-console": ["error", { "allow": ["warn", "error"] }],
"no-empty-function": "off", "no-empty-function": "off",

@ -32,6 +32,10 @@ export default class Common {
type: messages.SETTINGS_QUERY, type: messages.SETTINGS_QUERY,
}).then((settings) => { }).then((settings) => {
this.store.dispatch(settingActions.set(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);
}); });
} }
} }

@ -1,6 +1,8 @@
import actions from 'content/actions'; import actions from 'content/actions';
const defaultState = {}; const defaultState = {
keymaps: {},
};
export default function reducer(state = defaultState, action = {}) { export default function reducer(state = defaultState, action = {}) {
switch (action.type) { switch (action.type) {

@ -5,7 +5,7 @@ import settingReducer from 'content/reducers/setting';
describe("content setting reducer", () => { describe("content setting reducer", () => {
it('return the initial state', () => { it('return the initial state', () => {
let state = settingReducer(undefined, {}); let state = settingReducer(undefined, {});
expect(state).to.deep.equal({}); expect(state).to.deep.equal({ keymaps: {} });
}); });
it('return next state for SETTING_SET', () => { it('return next state for SETTING_SET', () => {