consome as store/reducers

This commit is contained in:
Shin'ya Ueoka 2017-09-14 22:04:42 +09:00
parent 6127fdc285
commit 83cb277ba2
17 changed files with 171 additions and 236 deletions

View file

@ -3,18 +3,11 @@ import * as inputActions from '../actions/input';
import * as consoleFrames from '../console/frames';
import * as scrolls from '../content/scrolls';
import * as histories from '../content/histories';
import actions from '../actions';
import Follow from '../content/follow';
import operations from '../operations';
import contentReducer from '../reducers/content';
consoleFrames.initialize(window.document);
browser.runtime.onMessage.addListener((action) => {
contentReducer(undefined, action);
return Promise.resolve();
});
window.addEventListener("keypress", (e) => {
if (e.target instanceof HTMLInputElement) {
return;
@ -49,11 +42,17 @@ const execOperation = (operation) => {
}
}
const update = (state) => {
if (!state.console.commandShown) {
window.focus();
consoleFrames.blur(window.document);
}
}
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case actions.CONSOLE_HIDE:
window.focus();
return consoleFrames.blur(window.document);
case 'state.changed':
return update(action.state);
case 'require.content.operation':
execOperation(action.operation);
return Promise.resolve();