Attempt to fix popup exclusion issues
This commit is contained in:
parent
2b4a1a5635
commit
e94c7edb38
|
@ -388,7 +388,7 @@ function saveStyle(style) {
|
|||
}
|
||||
codeIsUpdated = !existed
|
||||
|| 'sections' in style && !styleSectionsEqual(style, oldStyle)
|
||||
|| reason === 'exclusionsUpdate';
|
||||
|| reason === 'exclusionsUpdated';
|
||||
style = Object.assign({installDate: Date.now()}, oldStyle, style);
|
||||
return write(style, store);
|
||||
});
|
||||
|
@ -427,7 +427,7 @@ function saveStyle(style) {
|
|||
style.id = style.id || event.target.result;
|
||||
invalidateCache(existed ? {updated: style} : {added: style});
|
||||
if (notify) {
|
||||
const method = reason === 'exclusionsUpdate' ? reason :
|
||||
const method = reason === 'exclusionsUpdated' ? reason :
|
||||
existed ? 'styleUpdated' : 'styleAdded';
|
||||
notifyAllTabs({method, style, codeIsUpdated, reason});
|
||||
}
|
||||
|
@ -457,12 +457,12 @@ function compileExclusionRegexps(exclusions) {
|
|||
}
|
||||
|
||||
function isPageExcluded(matchUrl, exclusions = {}) {
|
||||
const values = Object.values(exclusions);
|
||||
if (!values.length) {
|
||||
const keys = Object.keys(exclusions);
|
||||
if (!keys.length) {
|
||||
return false;
|
||||
}
|
||||
compileExclusionRegexps(values);
|
||||
return values.some(exclude => {
|
||||
compileExclusionRegexps(keys);
|
||||
return keys.some(exclude => {
|
||||
const rx = cachedStyles.exclusions.get(exclude);
|
||||
return rx && rx.test(matchUrl);
|
||||
});
|
||||
|
|
|
@ -135,7 +135,7 @@ const exclusions = (() => {
|
|||
}
|
||||
|
||||
function onRuntimeMessage(msg) {
|
||||
if (msg.method === 'exclusionsUpdate' && msg.style && msg.style.exclusions) {
|
||||
if (msg.method === 'exclusionsUpdated' && msg.style && msg.style.exclusions) {
|
||||
update({list: Object.keys(msg.style.exclusions), isUpdating: true});
|
||||
// update popup, if loaded
|
||||
if (typeof popupExclusions !== 'undefined') {
|
||||
|
@ -156,7 +156,7 @@ const exclusions = (() => {
|
|||
// get last saved version
|
||||
API.getStyles({id: id || exclusions.id}).then(([style]) => {
|
||||
style.exclusions = exclusionList;
|
||||
style.reason = 'exclusionsUpdate';
|
||||
style.reason = 'exclusionsUpdated';
|
||||
API.saveStyle(style);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ var API = (() => {
|
|||
|
||||
function notifyAllTabs(msg) {
|
||||
const originalMessage = msg;
|
||||
const styleUpdated = msg.method === 'styleUpdated';
|
||||
const styleUpdated = msg.method === 'styleUpdated' || msg.method === 'exclusionsUpdated';
|
||||
if (styleUpdated || msg.method === 'styleAdded') {
|
||||
// apply/popup/manage use only meta for these two methods,
|
||||
// editor may need the full code but can fetch it directly,
|
||||
|
|
|
@ -156,11 +156,11 @@ const popupExclusions = (() => {
|
|||
className: 'lights-on',
|
||||
onComplete: () => (box.dataset.display = false),
|
||||
});
|
||||
document.body.style.height = '';
|
||||
if (ok) {
|
||||
handlePopupSave(style);
|
||||
entry.styleMeta = style;
|
||||
entry.classList.toggle('excluded', isExcluded(tabURL, style.exclusions));
|
||||
document.body.style.height = '';
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
|
Loading…
Reference in New Issue
Block a user