Skip to content

Commit

Permalink
Close tabs in background
Browse files Browse the repository at this point in the history
  • Loading branch information
mastef committed Sep 22, 2024
1 parent 89b2fed commit 17f69cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/TabManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,7 @@ class TabManager extends React.Component {
return _this2.state.tabsbyid[id];
});
if (tabs.length) {
for (var i = 0; i < tabs.length; i++) {
await browser.tabs.remove(tabs[i].id);
}
browser.runtime.sendMessage({command: "close_tabs", tabs: tabs});
} else {
var t = await browser.tabs.query({ currentWindow: true, active: true });
if (t && t.length > 0) {
Expand Down
10 changes: 7 additions & 3 deletions lib/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ async function discardTabs(tabs) {
}
}

async function closeTabs(tabs) {
for (var i = 0; i < tabs.length; i++) {
await browser.tabs.remove(tabs[i].id);
}
}

async function moveTabsToWindow(windowId, tabs) {
for (var i = 0; i < tabs.length; i++) {
var t = tabs[i];
Expand Down Expand Up @@ -759,9 +765,7 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
createWindowWithSessionTabs(request.window);
break;
case "close_tabs":
for (var i = 0; i < request.tabs.length; i++) {
browser.tabs.remove(request.tabs[i]);
}
closeTabs(request.tabs);
break;
}
});
Expand Down

0 comments on commit 17f69cf

Please sign in to comment.