Skip to content

Commit

Permalink
Attempt to fix popup exclusion issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Jul 22, 2018
1 parent 2b4a1a5 commit e94c7ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions background/storage.js
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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});
}
Expand Down Expand Up @@ -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);
});
Expand Down
4 changes: 2 additions & 2 deletions js/exclusions.js
Expand Up @@ -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') {
Expand All @@ -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);
});
}
Expand Down
2 changes: 1 addition & 1 deletion js/messaging.js
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion popup/popup-exclusions.js
Expand Up @@ -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();
Expand Down

0 comments on commit e94c7ed

Please sign in to comment.