Fix error on keyword not found

jh-changes
Shin'ya Ueoka 6 years ago
parent ed2bd7d75e
commit f914d76ce8
  1. 6
      src/background/infrastructures/content-message-listener.js
  2. 3
      src/background/repositories/find.js
  3. 3
      src/background/usecases/link.js
  4. 6
      src/background/usecases/operation.js

@ -19,7 +19,11 @@ export default class ContentMessageListener {
run() { run() {
browser.runtime.onMessage.addListener((message, sender) => { browser.runtime.onMessage.addListener((message, sender) => {
try { try {
return this.onMessage(message, sender).catch((e) => { let ret = this.onMessage(message, sender);
if (!(ret instanceof Promise)) {
return {};
}
return ret.catch((e) => {
return browser.tabs.sendMessage(sender.tab.id, { return browser.tabs.sendMessage(sender.tab.id, {
type: messages.CONSOLE_SHOW_ERROR, type: messages.CONSOLE_SHOW_ERROR,
text: e.message, text: e.message,

@ -12,7 +12,8 @@ export default class FindRepository {
} }
setKeyword(keyword) { setKeyword(keyword) {
return this.cache.set(FIND_KEYWORD_KEY, keyword); this.cache.set(FIND_KEYWORD_KEY, keyword);
return Promise.resolve();
} }
} }

@ -8,8 +8,7 @@ export default class LinkInteractor {
} }
openToTab(url, tabId) { openToTab(url, tabId) {
this.tabPresenter.open(url, tabId); return this.tabPresenter.open(url, tabId);
} }
async openNewTab(url, openerId, background) { async openNewTab(url, openerId, background) {

@ -126,7 +126,7 @@ export default class OperationInteractor {
async showCommand() { async showCommand() {
let tab = await this.tabPresenter.getCurrent(); let tab = await this.tabPresenter.getCurrent();
this.consolePresenter.showCommand(tab.id, ''); return this.consolePresenter.showCommand(tab.id, '');
} }
async showOpenCommand(alter) { async showOpenCommand(alter) {
@ -173,12 +173,12 @@ export default class OperationInteractor {
async findStart() { async findStart() {
let tab = await this.tabPresenter.getCurrent(); let tab = await this.tabPresenter.getCurrent();
this.consolePresenter.showFind(tab.id); return this.consolePresenter.showFind(tab.id);
} }
async hideConsole() { async hideConsole() {
let tab = await this.tabPresenter.getCurrent(); let tab = await this.tabPresenter.getCurrent();
this.consolePresenter.hide(tab.id); return this.consolePresenter.hide(tab.id);
} }
onTabSelected(tabId) { onTabSelected(tabId) {