don't double-process 'styleUpdated' in manager

This commit is contained in:
tophf 2018-01-14 18:18:08 +03:00
parent dc1cd890ee
commit 4493c9e9f0
2 changed files with 6 additions and 3 deletions

View File

@ -159,7 +159,7 @@ function notifyAllTabs(msg) {
const affectsIcon = affectsAll || msg.affects.icon;
const affectsPopup = affectsAll || msg.affects.popup;
const affectsSelf = affectsPopup || msg.prefs;
// notify background page and all open popups
// notify all open extension pages and popups
if (affectsSelf) {
msg.tabId = undefined;
sendMessage(msg, ignoreChromeError);
@ -167,9 +167,9 @@ function notifyAllTabs(msg) {
// notify tabs
if (affectsTabs || affectsIcon) {
const notifyTab = tab => {
// own pages will be notified via runtime.sendMessage later
if (!styleUpdated
&& (affectsTabs || URLS.optionsUI.includes(tab.url))
// own pages are already notified via sendMessage
&& !(affectsSelf && tab.url.startsWith(URLS.ownOrigin))
// skip lazy-loaded aka unloaded tabs that seem to start loading on message in FF
&& (!FIREFOX || tab.width)) {

View File

@ -514,8 +514,11 @@ Object.assign(handleEvent, {
});
function handleUpdate(style, {reason, method} = {}) {
function handleUpdate(style, {reason, method, codeIsUpdated} = {}) {
if (reason === 'editPreview') return;
// the style was toggled and refreshAllTabs() sent a mini-notification,
// but we've already processed 'styleUpdated' sent directly from notifyAllTabs()
if (!style.sections) return;
let entry;
let oldEntry = $(ENTRY_ID_PREFIX + style.id);
if (oldEntry && method === 'styleUpdated') {