Fixing exemption to be stored in memory rather than storage (prevents exemption from being remembered on restart).
This commit is contained in:
parent
bd72b4e759
commit
a29fae0893
1 changed files with 19 additions and 7 deletions
|
@ -6,6 +6,7 @@ const assignManager = {
|
||||||
MENU_REMOVE_ID: "remove-open-in-this-container",
|
MENU_REMOVE_ID: "remove-open-in-this-container",
|
||||||
storageArea: {
|
storageArea: {
|
||||||
area: browser.storage.local,
|
area: browser.storage.local,
|
||||||
|
exemptedTabs: {},
|
||||||
|
|
||||||
getSiteStoreKey(pageUrl) {
|
getSiteStoreKey(pageUrl) {
|
||||||
const url = new window.URL(pageUrl);
|
const url = new window.URL(pageUrl);
|
||||||
|
@ -13,6 +14,22 @@ const assignManager = {
|
||||||
return `${storagePrefix}${url.hostname}`;
|
return `${storagePrefix}${url.hostname}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setExempted(pageUrl, tabId) {
|
||||||
|
if (!(tabId in this.exemptedTabs)) {
|
||||||
|
this.exemptedTabs[tabId] = [];
|
||||||
|
}
|
||||||
|
const siteStoreKey = this.getSiteStoreKey(pageUrl);
|
||||||
|
this.exemptedTabs[tabId].push(siteStoreKey);
|
||||||
|
},
|
||||||
|
|
||||||
|
isExempted(pageUrl, tabId) {
|
||||||
|
if (!(tabId in this.exemptedTabs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const siteStoreKey = this.getSiteStoreKey(pageUrl);
|
||||||
|
return this.exemptedTabs[tabId].includes(siteStoreKey);
|
||||||
|
},
|
||||||
|
|
||||||
get(pageUrl) {
|
get(pageUrl) {
|
||||||
const siteStoreKey = this.getSiteStoreKey(pageUrl);
|
const siteStoreKey = this.getSiteStoreKey(pageUrl);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -73,12 +90,7 @@ const assignManager = {
|
||||||
// We return here so the confirm page can load the tab when exempted
|
// We return here so the confirm page can load the tab when exempted
|
||||||
async _exemptTab(m) {
|
async _exemptTab(m) {
|
||||||
const pageUrl = m.pageUrl;
|
const pageUrl = m.pageUrl;
|
||||||
// If we have existing data and for some reason it hasn't been deleted etc lets update it
|
this.storageArea.setExempted(pageUrl, m.tabId);
|
||||||
const siteSettings = await this.storageArea.get(pageUrl);
|
|
||||||
if (siteSettings) {
|
|
||||||
siteSettings.exempted.push(m.tabId);
|
|
||||||
await this.storageArea.set(pageUrl, siteSettings);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,7 +112,7 @@ const assignManager = {
|
||||||
if (!siteSettings
|
if (!siteSettings
|
||||||
|| userContextId === siteSettings.userContextId
|
|| userContextId === siteSettings.userContextId
|
||||||
|| tab.incognito
|
|| tab.incognito
|
||||||
|| siteSettings.exempted.includes(tab.id)) {
|
|| this.storageArea.isExempted(options.url, tab.id)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue