diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-16 21:28:21 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-16 21:28:21 +0900 |
commit | 27702ef40236ca055e63373b2ee81d399d124cca (patch) | |
tree | 0b991574661bf12323c39b1b9157b0b6124b75de /src | |
parent | c7a3dd16e666b5f844bc98f19e58a3fe9967b5a4 (diff) |
remove actions from content
Diffstat (limited to 'src')
-rw-r--r-- | src/background/index.js | 13 | ||||
-rw-r--r-- | src/console/frames.js | 11 | ||||
-rw-r--r-- | src/content/index.js | 11 | ||||
-rw-r--r-- | src/messages/index.js | 4 |
4 files changed, 12 insertions, 27 deletions
diff --git a/src/background/index.js b/src/background/index.js index f329a9c..cbd4721 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -56,18 +56,11 @@ const keyQueueChanged = (sendToTab, state) => { return browser.tabs.sendMessage(sendToTab.id, action); }; -const handleMessage = (action, sendToTab) => { - backgroundStore.dispatch(action); - - return browser.tabs.sendMessage(sendToTab.id, action); -}; - -browser.runtime.onMessage.addListener((action, sender) => { - handleMessage(action, sender.tab); -}); - browser.runtime.onMessage.addListener((message) => { switch (message.type) { + case messages.KEYDOWN: + backgroundStore.dispatch(inputActions.keyPress(message.code, message.ctrl)); + break; case messages.CONSOLE_BLURRED: backgroundStore.dispatch(consoleActions.hide()); break; diff --git a/src/console/frames.js b/src/console/frames.js index 0b6f3e2..ec1e38c 100644 --- a/src/console/frames.js +++ b/src/console/frames.js @@ -1,5 +1,4 @@ import './console-frame.scss'; -import * as consoleActions from '../actions/console'; const initialize = (doc) => { let iframe = doc.createElement('iframe'); @@ -11,17 +10,9 @@ const initialize = (doc) => { return iframe; } -const showCommand = (text) => { - return browser.runtime.sendMessage(consoleActions.showCommand(text)); -}; - -const showError = (text) => { - return browser.runtime.sendMessage(consoleActions.showError(text)); -} - const blur = (doc) => { let iframe = doc.getElementById('vimvixen-console-frame'); iframe.blur(); } -export { initialize, showCommand, showError, blur }; +export { initialize, blur }; diff --git a/src/content/index.js b/src/content/index.js index 43d632e..5d3735c 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -1,5 +1,4 @@ import '../console/console-frame.scss'; -import * as inputActions from '../actions/input'; import * as consoleFrames from '../console/frames'; import * as scrolls from '../content/scrolls'; import * as histories from '../content/histories'; @@ -13,11 +12,11 @@ window.addEventListener("keypress", (e) => { if (e.target instanceof HTMLInputElement) { return; } - browser.runtime.sendMessage(inputActions.keyPress(e.which, e.ctrlKey)) - .catch((err) => { - console.error("Vim Vixen:", err); - return consoleFrames.showError(err.message); - }); + browser.runtime.sendMessage({ + type: messages.KEYDOWN, + code: e.which, + ctrl: e.ctrl + }); }); const execOperation = (operation) => { diff --git a/src/messages/index.js b/src/messages/index.js index ad036a8..3bdecca 100644 --- a/src/messages/index.js +++ b/src/messages/index.js @@ -4,5 +4,7 @@ export default { CONSOLE_BLURRED: 'console.blured', CONSOLE_ENTERED: 'console.entered', - CONSOLE_CHANGEED: 'console.changed' + CONSOLE_CHANGEED: 'console.changed', + + KEYDOWN: 'keydown' }; |