diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/popup.js | 2 | ||||
-rw-r--r-- | src/ui/ui.js | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/ui/popup.js b/src/ui/popup.js index 310ecac..c29b94d 100644 --- a/src/ui/popup.js +++ b/src/ui/popup.js @@ -164,7 +164,7 @@ addEventListener("unload", e => { sitesUI = new UI.Sites(document.getElementById("sites")); sitesUI.onChange = (row) => { - pendingReload(!row.temp2perm); + pendingReload(sitesUI.anyPermissionsChanged()); if (optionsClosed) return; browser.tabs.query({ url: browser.extension.getURL( diff --git a/src/ui/ui.js b/src/ui/ui.js index c2e12b0..a387d6e 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -346,6 +346,11 @@ var UI = (() => { allSiteRows() { return this.table.querySelectorAll("tr.site"); } + + anyPermissionsChanged() { + return Array.from(this.allSiteRows()).some(row => row.permissionsChanged); + } + clear() { debug("Clearing list", this.table); @@ -399,17 +404,16 @@ var UI = (() => { let tempToggle = preset.parentNode.querySelector("input.temp"); if (ev.type === "change") { - row.temp2perm = false; + row.permissionsChanged = false; + if (!row._originalPerms) { + row._originalPerms = row.perms.clone(); + } let policy = UI.policy; let presetValue = preset.value; let policyPreset = presetValue.startsWith("T_") ? policy[presetValue.substring(2)].tempTwin : policy[presetValue]; - if (policyPreset) { - if (row.perms !== policyPreset) { - row.temp2perm = row.perms && - (policyPreset.tempTwin === row.perms || policyPreset === row.perms._tempTwin); - row.perms = policyPreset; - } + if (policyPreset && row.perms !== policyPreset) { + row.perms = policyPreset; } if (preset.checked) { row.dataset.preset = preset.value; @@ -443,6 +447,7 @@ var UI = (() => { this.customize(perms, preset, row); } } + row.permissionsChanged = !row.perms.sameAs(row._originalPerms); fireOnChange(this, row); } else if (!(isCap || isTemp) && ev.type === "click") { this.customize(row.perms, preset, row); |