aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-09 20:25:21 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-09 20:25:21 +0900
commit6a2bfc51baf22bcf66153076120d48d894a3967d (patch)
tree7c112128b94d8259c1668b608406983070d3e00e /src
parent0eed357a5e1ceb3061d88ef99a612bb8c4526fa7 (diff)
receive message of console
Diffstat (limited to 'src')
-rw-r--r--src/console/console-frame.js6
-rw-r--r--src/console/console.js24
2 files changed, 15 insertions, 15 deletions
diff --git a/src/console/console-frame.js b/src/console/console-frame.js
index a590da9..f07d8ab 100644
--- a/src/console/console-frame.js
+++ b/src/console/console-frame.js
@@ -1,5 +1,4 @@
import './console-frame.scss';
-import * as messages from '../shared/messages';
export default class ConsoleFrame {
constructor(win) {
@@ -33,9 +32,10 @@ export default class ConsoleFrame {
type: 'vimvixen.console.show.error',
text: text
};
- messages.send(this.element.contentWindow, message);
this.errorShown = true;
this.element.blur();
+
+ return browser.runtime.sendMessage(message);
}
showFrame() {
@@ -53,7 +53,7 @@ export default class ConsoleFrame {
}
setCompletions(completions) {
- messages.send(this.element.contentWindow, {
+ return browser.runtime.sendMessage({
type: 'vimvixen.console.set.completions',
completions: completions
});
diff --git a/src/console/console.js b/src/console/console.js
index ae05001..23a26ef 100644
--- a/src/console/console.js
+++ b/src/console/console.js
@@ -116,6 +116,8 @@ const showCommand = (text) => {
let container = window.document.querySelector('#vimvixen-console-completion');
container.innerHTML = '';
messages.send(parent, keyupMessage(input));
+
+ return Promise.resolve();
}
const showError = (text) => {
@@ -128,6 +130,8 @@ const showError = (text) => {
let completion = window.document.querySelector('#vimvixen-console-completion');
completion.style.display = 'none';
+
+ return Promise.resolve();
}
const createCompletionTitle = (text) => {
@@ -177,6 +181,8 @@ const setCompletions = (completions) => {
let input = window.document.querySelector('#vimvixen-console-command-input');
completionOrigin = input.value.split(' ')[0];
+
+ return Promise.resolve();
}
const selectCompletion = (target) => {
@@ -193,21 +199,15 @@ const selectCompletion = (target) => {
});
};
-messages.receive(window, (message) => {
- switch (message.type) {
- case 'vimvixen.console.show.error':
- showError(message.text);
- break;
- case 'vimvixen.console.set.completions':
- setCompletions(message.completions);
- break;
- }
-});
-
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
+ case 'vimvixen.console.show.error':
+ return showError(action.text);
+ case 'vimvixen.console.set.completions':
+ return setCompletions(action.completions);
case 'vimvixen.console.show.command':
return showCommand(action.text);
+ default:
+ return Promise.resolve();
}
- return Promise.resolve();
});