Add: styleViaAPI updateCount
This commit is contained in:
parent
39d21c3d29
commit
ff3bf6f52d
|
@ -1,4 +1,4 @@
|
|||
/* global API_METHODS styleManager CHROME prefs */
|
||||
/* global API_METHODS styleManager CHROME prefs updateIconBadge */
|
||||
'use strict';
|
||||
|
||||
API_METHODS.styleViaAPI = !CHROME && (() => {
|
||||
|
@ -9,6 +9,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
|
|||
styleAdded,
|
||||
styleReplaceAll,
|
||||
prefChanged,
|
||||
updateCount,
|
||||
};
|
||||
const NOP = Promise.resolve(new Error('NOP'));
|
||||
const onError = () => {};
|
||||
|
@ -30,6 +31,14 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
|
|||
.then(maybeToggleObserver);
|
||||
};
|
||||
|
||||
function updateCount(request, {tab, frameId}) {
|
||||
if (frameId) {
|
||||
throw new Error('we do not count styles for frames');
|
||||
}
|
||||
const {frameStyles} = getCachedData(tab.id, frameId);
|
||||
updateIconBadge(tab.id, Object.keys(frameStyles).length);
|
||||
}
|
||||
|
||||
function styleApply({id = null, ignoreUrlCheck = false}, {tab, frameId, url}) {
|
||||
if (prefs.get('disableAll')) {
|
||||
return NOP;
|
||||
|
|
Loading…
Reference in New Issue
Block a user