Merge pull request #774 from jonathanKingston/hidden-tab-open
Add a tab observer to show hidden tabs as there are many tab creation…
This commit is contained in:
commit
bc9660f76e
2 changed files with 17 additions and 23 deletions
|
@ -52,12 +52,6 @@ const backgroundLogic = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async openTab(options) {
|
async openTab(options) {
|
||||||
const userContextId = ("userContextId" in options) ? options.userContextId : 0;
|
|
||||||
const cookieStoreId = backgroundLogic.cookieStoreId(userContextId);
|
|
||||||
// Unhide all hidden tabs
|
|
||||||
this.showTabs({
|
|
||||||
cookieStoreId
|
|
||||||
});
|
|
||||||
return this.openNewTab(options);
|
return this.openNewTab(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ const messageHandler = {
|
||||||
// We use this to catch redirected tabs that have just opened
|
// We use this to catch redirected tabs that have just opened
|
||||||
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
||||||
LAST_CREATED_TAB_TIMER: 2000,
|
LAST_CREATED_TAB_TIMER: 2000,
|
||||||
|
unhideQueue: [],
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// Handles messages from webextension code
|
// Handles messages from webextension code
|
||||||
|
@ -87,20 +88,6 @@ const messageHandler = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.tabs.onCreated.addListener((tab) => {
|
|
||||||
// This works at capturing the tabs as they are created
|
|
||||||
// However we need onFocusChanged and onActivated to capture the initial tab
|
|
||||||
if (tab.id === -1) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
browser.tabs.onRemoved.addListener((tabId) => {
|
|
||||||
if (tabId === -1) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
browser.tabs.onActivated.addListener((info) => {
|
browser.tabs.onActivated.addListener((info) => {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
browser.tabs.get(info.tabId).then((tab) => {
|
browser.tabs.get(info.tabId).then((tab) => {
|
||||||
|
@ -127,14 +114,27 @@ const messageHandler = {
|
||||||
});
|
});
|
||||||
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
||||||
|
|
||||||
|
browser.tabs.onCreated.addListener((tab) => {
|
||||||
// lets remember the last tab created so we can close it if it looks like a redirect
|
// lets remember the last tab created so we can close it if it looks like a redirect
|
||||||
browser.tabs.onCreated.addListener((details) => {
|
this.lastCreatedTab = tab;
|
||||||
this.lastCreatedTab = details;
|
if (tab.cookieStoreId) {
|
||||||
|
this.unhideContainer(tab.cookieStoreId);
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.lastCreatedTab = null;
|
this.lastCreatedTab = null;
|
||||||
}, this.LAST_CREATED_TAB_TIMER);
|
}, this.LAST_CREATED_TAB_TIMER);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async unhideContainer(cookieStoreId) {
|
||||||
|
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||||
|
this.unhideQueue.push(cookieStoreId);
|
||||||
|
// Unhide all hidden tabs
|
||||||
|
await backgroundLogic.showTabs({
|
||||||
|
cookieStoreId
|
||||||
|
});
|
||||||
|
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async onFocusChangedCallback(windowId) {
|
async onFocusChangedCallback(windowId) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue