Skip to content

Commit

Permalink
Fix MAC-689
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
lesleyjanenorton committed Dec 10, 2021
1 parent cbcae35 commit e87be3d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
const permissionId = el.dataset.permissionId;
el.addEventListener("change", async() => {
if (el.checked) {
disablePermissionsInputs();
const granted = await browser.permissions.request({ permissions: [permissionId] });
if (!granted) {
el.checked = false;
enablePermissionsInputs();
}
return;
}
Expand Down Expand Up @@ -91,6 +105,7 @@ function resetOnboarding() {
async function resetPermissionsUi() {
await maybeShowPermissionsWarningIcon();
await setUpCheckBoxes();
enablePermissionsInputs();
}

browser.permissions.onAdded.addListener(resetPermissionsUi);
Expand Down

0 comments on commit e87be3d

Please sign in to comment.