Merge pull request #1643 from libklein/bugfix/set-current-page-id-after-closing-tab

Set currentTabId in remove tab.
This commit is contained in:
Sami Vänttinen 2022-06-20 07:09:53 +03:00 committed by GitHub
commit 32ee510565
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,11 +37,16 @@ browser.tabs.onCreated.addListener((tab) => {
* @param {integer} tabId
* @param {object} removeInfo
*/
browser.tabs.onRemoved.addListener((tabId, removeInfo) => {
delete page.tabs[tabId];
browser.tabs.onRemoved.addListener(async function(tabId, removeInfo) {
if (page.currentTabId === tabId) {
page.currentTabId = -1;
const activeTabs = await browser.tabs.query({ active: true, currentWindow: true });
if (activeTabs.length > 0) {
page.currentTabId = activeTabs[0].id;
} else {
page.currentTabId = -1;
}
}
delete page.tabs[tabId];
});
/**