Attempt to update icon count
This commit is contained in:
parent
4fcb1a88d7
commit
8a6011de8c
|
@ -381,16 +381,22 @@ function updateIcon({tab, styles}) {
|
|||
return;
|
||||
}
|
||||
getTabRealURL(tab)
|
||||
.then(url => getStyles({matchUrl: url, asHash: true}))
|
||||
.then(url => getStyles({matchUrl: url, asHash: true, omitCode: true}))
|
||||
.then(stylesReceived);
|
||||
|
||||
function getLength(styles) {
|
||||
const keys = Object.keys(styles || {});
|
||||
// Using "included" because styles may not include the psuedo-section added by the
|
||||
// filterStylesInternal function
|
||||
return String(keys.filter(key => styles[key][0] ? styles[key][0].included : false).length);
|
||||
}
|
||||
|
||||
function stylesReceived(styles) {
|
||||
const disableAll = 'disableAll' in styles ? styles.disableAll : prefs.get('disableAll');
|
||||
const postfix = disableAll ? 'x' : !styles.length ? 'w' : '';
|
||||
const color = prefs.get(disableAll ? 'badgeDisabled' : 'badgeNormal');
|
||||
const text = prefs.get('show-badge') && styles.length ? String(styles.length) : '';
|
||||
const text = prefs.get('show-badge') && styles.length ? getLength(styles) : '';
|
||||
const iconset = ['', 'light/'][prefs.get('iconset')] || '';
|
||||
|
||||
let tabIcon = tabIcons.get(tab.id);
|
||||
if (!tabIcon) tabIcons.set(tab.id, (tabIcon = {}));
|
||||
|
||||
|
|
|
@ -315,6 +315,7 @@ function filterStylesInternal({
|
|||
});
|
||||
if (asHash) {
|
||||
if (sections.length && sections[0] !== '') {
|
||||
sections.unshift({included: !isPageExcluded(matchUrl, style.exclusions)});
|
||||
filtered[style.id] = sections;
|
||||
filtered.length++;
|
||||
}
|
||||
|
@ -488,7 +489,7 @@ function getApplicableSections({
|
|||
}
|
||||
// Show excluded style in popup
|
||||
if (excluded) {
|
||||
return [''];
|
||||
return [{}];
|
||||
}
|
||||
const sections = [];
|
||||
for (const section of style.sections) {
|
||||
|
|
|
@ -162,7 +162,7 @@ const exclusions = (() => {
|
|||
style.exclusions = exclusionList;
|
||||
style.reason = 'exclusionsUpdated';
|
||||
API.saveStyle(style);
|
||||
notifyAllTabs({method: 'exclusionsUpdated', style, id});
|
||||
notifyAllTabs({method: 'exclusionsUpdated', style, id, excluded: exclusionList});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -157,12 +157,13 @@ const popupExclusions = (() => {
|
|||
onComplete: () => (box.dataset.display = false),
|
||||
});
|
||||
document.body.style.height = '';
|
||||
const excluded = isExcluded(tabURL, style.exclusions);
|
||||
if (ok) {
|
||||
handlePopupSave(style);
|
||||
entry.styleMeta = style;
|
||||
entry.classList.toggle('excluded', isExcluded(tabURL, style.exclusions));
|
||||
entry.classList.toggle('excluded', excluded);
|
||||
}
|
||||
notifyAllTabs({method: 'exclusionsUpdated', style, id: entry.styleId});
|
||||
notifyAllTabs({method: 'exclusionsUpdated', style, id: entry.styleId, affects: true, excluded});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user