diff options
Diffstat (limited to 'src/background/components/background.js')
-rw-r--r-- | src/background/components/background.js | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/background/components/background.js b/src/background/components/background.js index 2d94310..fae3fbb 100644 --- a/src/background/components/background.js +++ b/src/background/components/background.js @@ -1,6 +1,8 @@ import messages from 'shared/messages'; import * as operationActions from 'background/actions/operation'; -import * as settingsActions from 'settings/actions/setting'; +import * as commandActions from 'background/actions/command'; +import * as settingActions from 'background/actions/setting'; +import * as findActions from 'background/actions/find'; import * as tabActions from 'background/actions/tab'; import * as commands from 'shared/commands'; @@ -22,6 +24,8 @@ export default class BackgroundComponent { onMessage(message, sender) { let settings = this.store.getState().setting; + let find = this.store.getState().find; + switch (message.type) { case messages.BACKGROUND_OPERATION: return this.store.dispatch( @@ -29,25 +33,31 @@ export default class BackgroundComponent { sender); case messages.OPEN_URL: if (message.newTab) { - return this.store.dispatch( - tabActions.openNewTab(message.url), sender); + let action = tabActions.openNewTab( + message.url, sender.tab.id, message.background, + settings.value.properties.adjacenttab); + return this.store.dispatch(action, sender); } return this.store.dispatch( tabActions.openToTab(message.url, sender.tab), sender); case messages.CONSOLE_ENTER_COMMAND: - return commands.exec(message.text, settings.value).catch((e) => { - return browser.tabs.sendMessage(sender.tab.id, { - type: messages.CONSOLE_SHOW_ERROR, - text: e.message, - }); - }); + this.store.dispatch( + commandActions.exec(message.text, settings.value), + sender + ); + return this.broadcastSettingsChanged(); case messages.SETTINGS_QUERY: return Promise.resolve(this.store.getState().setting.value); case messages.CONSOLE_QUERY_COMPLETIONS: return commands.complete(message.text, settings.value); case messages.SETTINGS_RELOAD: - this.store.dispatch(settingsActions.load()); + this.store.dispatch(settingActions.load()); return this.broadcastSettingsChanged(); + case messages.FIND_GET_KEYWORD: + return Promise.resolve(find.keyword); + case messages.FIND_SET_KEYWORD: + this.store.dispatch(findActions.setKeyword(message.keyword)); + return Promise.resolve({}); } } |