Skip to content

Commit

Permalink
Move tabs to window in the background
Browse files Browse the repository at this point in the history
  • Loading branch information
mastef committed Sep 22, 2024
1 parent 1b0e1ca commit 7374bf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/TabManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1427,11 +1427,9 @@ class TabManager extends React.Component {
var tabs = Object.keys(this.state.selection).map(function(id) {
return _this6.state.tabsbyid[id];
});
for (var i = 0; i < tabs.length; i++) {
var t = tabs[i];
await browser.tabs.move(t.id, { windowId: windowId, index: -1 });
await browser.tabs.update(t.id, { pinned: t.pinned });
}

browser.runtime.sendMessage({command: "move_tabs_to_window", window_id: windowId, tabs: tabs});

this.setState({
selection: {}
});
Expand Down
11 changes: 11 additions & 0 deletions lib/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ browser.runtime.onStartup.addListener(
}
);

async function moveTabsToWindow(windowId, tabs) {
for (var i = 0; i < tabs.length; i++) {
var t = tabs[i];
await browser.tabs.move(t.id, {windowId: windowId, index: -1});
await browser.tabs.update(t.id, {pinned: t.pinned});
}
}

async function createWindowWithTabs(tabs, isIncognito) {

var pinnedIndex = 0;
Expand Down Expand Up @@ -715,6 +723,9 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
case "update_tab_count":
updateTabCount();
break;
case "move_tabs_to_window":
moveTabsToWindow(request.window_id, request.tabs);
break;
case "focus_on_tab_and_window":
focusOnTabAndWindow(request.tab);
break;
Expand Down

0 comments on commit 7374bf6

Please sign in to comment.