Skip to content

Commit dd57158

Browse files
#885 disables move tab to a new window when only one tab is opened
1 parent 99db192 commit dd57158

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/js/popup.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ const Logic = {
212212
return false;
213213
},
214214

215+
async noOfTabs() {
216+
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
217+
return activeTabs.length;
218+
},
219+
215220
async refreshIdentities() {
216221
const [identities, state] = await Promise.all([
217222
browser.contextualIdentities.query({}),
@@ -717,13 +722,21 @@ Logic.registerPanel(P_CONTAINER_INFO, {
717722

718723
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
719724
} else {
720-
Logic.addEnterHandler(moveTabsEl, async function () {
721-
await browser.runtime.sendMessage({
722-
method: "moveTabsToWindow",
723-
windowId: browser.windows.WINDOW_ID_CURRENT,
724-
cookieStoreId: Logic.currentIdentity().cookieStoreId,
725-
});
726-
window.close();
725+
Logic.noOfTabs().then(result => {
726+
if (result === 1) {
727+
moveTabsEl.classList.remove("clickable");
728+
} else {
729+
Logic.addEnterHandler(moveTabsEl, async function () {
730+
await browser.runtime.sendMessage({
731+
method: "moveTabsToWindow",
732+
windowId: browser.windows.WINDOW_ID_CURRENT,
733+
cookieStoreId: Logic.currentIdentity().cookieStoreId,
734+
});
735+
window.close();
736+
});
737+
}
738+
}).catch(error => {
739+
throw new Error(error);
727740
});
728741
}
729742
} catch (e) {

0 commit comments

Comments
 (0)