summaryrefslogtreecommitdiff
path: root/src/ui/ui.js
diff options
context:
space:
mode:
authorhackademix2019-05-26 15:42:00 +0200
committerhackademix2019-05-26 15:42:00 +0200
commit23fb55bf38469a5dcc2dd7b8c45807f5535d6382 (patch)
treeab444b03dbe5af311d55af4ce7109eb1b8de9166 /src/ui/ui.js
parentb06ec5d1c81fe24f1e0c853a22360c29b1051f4a (diff)
downloadnoscript-23fb55bf38469a5dcc2dd7b8c45807f5535d6382.tar.gz
noscript-23fb55bf38469a5dcc2dd7b8c45807f5535d6382.tar.xz
noscript-23fb55bf38469a5dcc2dd7b8c45807f5535d6382.zip
More accurate algorithm to account for permissions changes in the UI triggering automatic reloads.
Diffstat (limited to 'src/ui/ui.js')
-rw-r--r--src/ui/ui.js19
1 files changed, 12 insertions, 7 deletions
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);