broadcast an action

jh-changes
Shin'ya Ueoka 7 years ago
parent 3d35db9fc1
commit 0eed357a5e
  1. 2
      src/background/index.js
  2. 2
      src/console/console-frame.js
  3. 11
      src/console/console.js
  4. 11
      src/content/index.js

@ -96,5 +96,7 @@ browser.runtime.onMessage.addListener((request, sender) => {
items: items
};
});
default:
return browser.tabs.sendMessage(sender.tab.id, request);
}
});

@ -22,8 +22,8 @@ export default class ConsoleFrame {
type: 'vimvixen.console.show.command',
text: text
};
messages.send(this.element.contentWindow, message);
this.errorShown = false;
return browser.runtime.sendMessage(message);
}
showError(text) {

@ -195,9 +195,6 @@ const selectCompletion = (target) => {
messages.receive(window, (message) => {
switch (message.type) {
case 'vimvixen.console.show.command':
showCommand(message.text);
break;
case 'vimvixen.console.show.error':
showError(message.text);
break;
@ -206,3 +203,11 @@ messages.receive(window, (message) => {
break;
}
});
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case 'vimvixen.console.show.command':
return showCommand(action.text);
}
return Promise.resolve();
});

@ -11,19 +11,16 @@ let vvConsole = new ConsoleFrame(window);
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case actions.CMD_OPEN:
vvConsole.showCommand('');
break;
return vvConsole.showCommand('');
case actions.CMD_TABS_OPEN:
if (action.alter) {
// alter url
vvConsole.showCommand('open ' + window.location.href);
return vvConsole.showCommand('open ' + window.location.href);
} else {
vvConsole.showCommand('open ');
return vvConsole.showCommand('open ');
}
break;
case actions.CMD_BUFFER:
vvConsole.showCommand('buffer ');
break;
return vvConsole.showCommand('buffer ');
case actions.SCROLL_LINES:
scrolls.scrollLines(window, action.count);
break;