Fix MAC-689
This prevents permission prompts from getting lost when multiple permission checkboxes are checked before their corresponding prompts are accepted or declined and one of the permissions requires a reboot when enabled (Jira ticket MAC-689)
This commit is contained in:
parent
cbcae353a3
commit
e87be3df2a
1 changed files with 15 additions and 0 deletions
|
@ -8,13 +8,27 @@ async function setUpCheckBoxes() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disablePermissionsInputs() {
|
||||||
|
document.querySelectorAll("[data-permission-id").forEach(el => {
|
||||||
|
el.disabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function enablePermissionsInputs() {
|
||||||
|
document.querySelectorAll("[data-permission-id").forEach(el => {
|
||||||
|
el.disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelectorAll("[data-permission-id").forEach(async(el) => {
|
document.querySelectorAll("[data-permission-id").forEach(async(el) => {
|
||||||
const permissionId = el.dataset.permissionId;
|
const permissionId = el.dataset.permissionId;
|
||||||
el.addEventListener("change", async() => {
|
el.addEventListener("change", async() => {
|
||||||
if (el.checked) {
|
if (el.checked) {
|
||||||
|
disablePermissionsInputs();
|
||||||
const granted = await browser.permissions.request({ permissions: [permissionId] });
|
const granted = await browser.permissions.request({ permissions: [permissionId] });
|
||||||
if (!granted) {
|
if (!granted) {
|
||||||
el.checked = false;
|
el.checked = false;
|
||||||
|
enablePermissionsInputs();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +105,7 @@ function resetOnboarding() {
|
||||||
async function resetPermissionsUi() {
|
async function resetPermissionsUi() {
|
||||||
await maybeShowPermissionsWarningIcon();
|
await maybeShowPermissionsWarningIcon();
|
||||||
await setUpCheckBoxes();
|
await setUpCheckBoxes();
|
||||||
|
enablePermissionsInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.permissions.onAdded.addListener(resetPermissionsUi);
|
browser.permissions.onAdded.addListener(resetPermissionsUi);
|
||||||
|
|
Loading…
Add table
Reference in a new issue