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) => {
|
||||
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;
|
||||
}
|
||||
|
@ -91,6 +105,7 @@ function resetOnboarding() {
|
|||
async function resetPermissionsUi() {
|
||||
await maybeShowPermissionsWarningIcon();
|
||||
await setUpCheckBoxes();
|
||||
enablePermissionsInputs();
|
||||
}
|
||||
|
||||
browser.permissions.onAdded.addListener(resetPermissionsUi);
|
||||
|
|
Loading…
Add table
Reference in a new issue