#885 disables move tab to a new window when only one tab is opened

This commit is contained in:
shivangikakkar 2018-09-20 21:34:19 +05:30
parent 99db192792
commit dd57158ab5

View file

@ -212,6 +212,11 @@ const Logic = {
return false; return false;
}, },
async noOfTabs() {
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
return activeTabs.length;
},
async refreshIdentities() { async refreshIdentities() {
const [identities, state] = await Promise.all([ const [identities, state] = await Promise.all([
browser.contextualIdentities.query({}), browser.contextualIdentities.query({}),
@ -717,13 +722,21 @@ Logic.registerPanel(P_CONTAINER_INFO, {
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling); moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
} else { } else {
Logic.addEnterHandler(moveTabsEl, async function () { Logic.noOfTabs().then(result => {
await browser.runtime.sendMessage({ if (result === 1) {
method: "moveTabsToWindow", moveTabsEl.classList.remove("clickable");
windowId: browser.windows.WINDOW_ID_CURRENT, } else {
cookieStoreId: Logic.currentIdentity().cookieStoreId, Logic.addEnterHandler(moveTabsEl, async function () {
}); await browser.runtime.sendMessage({
window.close(); method: "moveTabsToWindow",
windowId: browser.windows.WINDOW_ID_CURRENT,
cookieStoreId: Logic.currentIdentity().cookieStoreId,
});
window.close();
});
}
}).catch(error => {
throw new Error(error);
}); });
} }
} catch (e) { } catch (e) {