Avoid unnecessary reloads on temporary permissions revocation.

This commit is contained in:
hackademix 2020-08-03 20:38:03 +02:00
parent 51c9ac2c83
commit 1dd7d43384
2 changed files with 7 additions and 3 deletions

View File

@ -87,7 +87,7 @@ addEventListener("unload", e => {
"reload": reload, "reload": reload,
"temp-trust-page": e => sitesUI.tempTrustAll(), "temp-trust-page": e => sitesUI.tempTrustAll(),
"revoke-temp": e => { "revoke-temp": e => {
UI.revokeTemp(); UI.revokeTemp(sitesUI.hasTemp);
close(); close();
} }
}; };

View File

@ -90,11 +90,11 @@ var UI = (() => {
return await Messages.send("importSettings", {data}); return await Messages.send("importSettings", {data});
}, },
async revokeTemp() { async revokeTemp(reloadAffected = false) {
let policy = this.policy; let policy = this.policy;
Policy.hydrate(policy.dry(), policy); Policy.hydrate(policy.dry(), policy);
if (this.isDirty(true)) { if (this.isDirty(true)) {
await this.updateSettings({policy, reloadAffected: true}); await this.updateSettings({policy, reloadAffected});
} }
}, },
@ -637,9 +637,11 @@ var UI = (() => {
_populate(sites, sorter) { _populate(sites, sorter) {
this.clear(); this.clear();
let hasTemp = false;
if (sites instanceof Sites) { if (sites instanceof Sites) {
for (let [site, perms] of sites) { for (let [site, perms] of sites) {
this.append(site, site, perms); this.append(site, site, perms);
if (!hasTemp) hasTemp = perms.temp;
} }
} else { } else {
for (let site of sites) { for (let site of sites) {
@ -650,9 +652,11 @@ var UI = (() => {
} }
let {siteMatch, perms, contextMatch} = UI.policy.get(site, context); let {siteMatch, perms, contextMatch} = UI.policy.get(site, context);
this.append(site, siteMatch, perms, contextMatch); this.append(site, siteMatch, perms, contextMatch);
if (!hasTemp) hasTemp = perms.temp;
} }
this.sites = sites; this.sites = sites;
} }
this.hasTemp = hasTemp;
this.sort(sorter); this.sort(sorter);
} }