Rewrite nextTab, fix multiple windows

This commit is contained in:
Oliver Blanthorn 2017-02-13 23:01:00 +00:00
parent 5951a29ce7
commit db06783c8c

View file

@ -55,15 +55,16 @@ displayTab = (tab_id) ->
browser.browserAction.onClicked.addListener(handleBrowserAction) browser.browserAction.onClicked.addListener(handleBrowserAction)
nextTab = () -> nextTab = () ->
browser.tabs.query({active:true}).then((tabs) -> browser.windows.getCurrent().then(
id = tabs[0].id (window) ->
index = tabs[0].index browser.tabs.query({windowId:window.id}).then(
desIndex = index + 1 (tabs) ->
browser.tabs.query({}).then((tabs) -> active = (tab for tab in tabs when tab.active)[0]
desId = tab for tab in tabs when tab.index == desIndex nextIndex = (active.index + 1) % tabs.length
setTab(desId.id) desiredTab = (tab for tab in tabs when tab.index == nextIndex)[0]
) setTab(desiredTab.id)
) ).catch(console.error)
).catch(console.error)
setTab = (id) -> setTab = (id) ->
browser.tabs.update(id,{active:true}) browser.tabs.update(id,{active:true})