restructuring the code acc to the review
This commit is contained in:
parent
e57c556427
commit
fe0810b048
1 changed files with 35 additions and 34 deletions
|
@ -217,6 +217,22 @@ const Logic = {
|
||||||
return activeTabs.length;
|
return activeTabs.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_disableMoveTabs(message) {
|
||||||
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
const incompatEl = document.createElement("div");
|
||||||
|
|
||||||
|
moveTabsEl.classList.remove("clickable");
|
||||||
|
moveTabsEl.setAttribute("title", message);
|
||||||
|
|
||||||
|
fragment.appendChild(incompatEl);
|
||||||
|
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||||
|
incompatEl.textContent = message;
|
||||||
|
incompatEl.classList.add("container-info-tab-row");
|
||||||
|
|
||||||
|
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||||
|
},
|
||||||
|
|
||||||
async refreshIdentities() {
|
async refreshIdentities() {
|
||||||
const [identities, state] = await Promise.all([
|
const [identities, state] = await Promise.all([
|
||||||
browser.contextualIdentities.query({}),
|
browser.contextualIdentities.query({}),
|
||||||
|
@ -703,46 +719,31 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if the user has incompatible add-ons installed
|
// Check if the user has incompatible add-ons installed
|
||||||
|
let incompatible = false;
|
||||||
try {
|
try {
|
||||||
const incompatible = await browser.runtime.sendMessage({
|
incompatible = await browser.runtime.sendMessage({
|
||||||
method: "checkIncompatibleAddons"
|
method: "checkIncompatibleAddons"
|
||||||
});
|
});
|
||||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
|
||||||
if (incompatible) {
|
|
||||||
const fragment = document.createDocumentFragment();
|
|
||||||
const incompatEl = document.createElement("div");
|
|
||||||
|
|
||||||
moveTabsEl.classList.remove("clickable");
|
|
||||||
moveTabsEl.setAttribute("title", "Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
|
||||||
|
|
||||||
fragment.appendChild(incompatEl);
|
|
||||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
|
||||||
incompatEl.textContent = "Incompatible with other Experiments.";
|
|
||||||
incompatEl.classList.add("container-info-tab-row");
|
|
||||||
|
|
||||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const numTabs = await Logic.numTabs();
|
|
||||||
if (numTabs === 1) {
|
|
||||||
moveTabsEl.classList.remove("clickable");
|
|
||||||
} else {
|
|
||||||
Logic.addEnterHandler(moveTabsEl, async function () {
|
|
||||||
await browser.runtime.sendMessage({
|
|
||||||
method: "moveTabsToWindow",
|
|
||||||
windowId: browser.windows.WINDOW_ID_CURRENT,
|
|
||||||
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
|
||||||
});
|
|
||||||
window.close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error("Could not get the number of active tabs.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Could not check for incompatible add-ons.");
|
throw new Error("Could not check for incompatible add-ons.");
|
||||||
}
|
}
|
||||||
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
|
const numTabs = await Logic.numTabs();
|
||||||
|
if (incompatible) {
|
||||||
|
Logic._disableMoveTabs("Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||||
|
return;
|
||||||
|
} else if (numTabs === 1) {
|
||||||
|
Logic._disableMoveTabs("Cannot move a tab from a single-tab window.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logic.addEnterHandler(moveTabsEl, async function () {
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
method: "moveTabsToWindow",
|
||||||
|
windowId: browser.windows.WINDOW_ID_CURRENT,
|
||||||
|
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
||||||
|
});
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// This method is called when the panel is shown.
|
// This method is called when the panel is shown.
|
||||||
|
|
Loading…
Add table
Reference in a new issue