diff options
Diffstat (limited to 'src/background')
-rw-r--r-- | src/background/actions/tab.js | 18 | ||||
-rw-r--r-- | src/background/components/background.js | 6 | ||||
-rw-r--r-- | src/background/index.js | 10 |
3 files changed, 29 insertions, 5 deletions
diff --git a/src/background/actions/tab.js b/src/background/actions/tab.js index 40da55d..3c642fd 100644 --- a/src/background/actions/tab.js +++ b/src/background/actions/tab.js @@ -1,9 +1,21 @@ -const openNewTab = (url, openerTabId) => { - return browser.tabs.create({ url, openerTabId }); +const openNewTab = (url, openerTabId, background = false, adjacent = false) => { + if (adjacent) { + return browser.tabs.query({ + active: true, currentWindow: true + }).then((tabs) => { + return browser.tabs.create({ + url, + openerTabId, + active: !background, + index: tabs[0].index + 1 + }); + }); + } + return browser.tabs.create({ url, active: !background }); }; const openToTab = (url, tab) => { return browser.tabs.update(tab.id, { url: url }); }; -export { openToTab, openNewTab }; +export { openNewTab, openToTab }; diff --git a/src/background/components/background.js b/src/background/components/background.js index fdec8ec..fae3fbb 100644 --- a/src/background/components/background.js +++ b/src/background/components/background.js @@ -33,8 +33,10 @@ export default class BackgroundComponent { sender); case messages.OPEN_URL: if (message.newTab) { - return this.store.dispatch( - tabActions.openNewTab(message.url, sender.tab.id), 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); diff --git a/src/background/index.js b/src/background/index.js index 3ef712f..ff27796 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -3,6 +3,7 @@ import messages from 'shared/messages'; import BackgroundComponent from 'background/components/background'; import reducers from 'background/reducers'; import { createStore } from 'shared/store'; +import * as versions from 'shared/versions'; const store = createStore(reducers, (e, sender) => { console.error('Vim-Vixen:', e); @@ -17,3 +18,12 @@ const store = createStore(reducers, (e, sender) => { const backgroundComponent = new BackgroundComponent(store); store.dispatch(settingActions.load()); + +versions.checkUpdated().then((updated) => { + if (!updated) { + return; + } + return versions.notify(); +}).then(() => { + return versions.commit(); +}); |