From 4493c9e9f09945adebc4add5e7ee7a6eee41c9ae Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 14 Jan 2018 18:18:08 +0300 Subject: [PATCH] don't double-process 'styleUpdated' in manager --- js/messaging.js | 4 ++-- manage/manage.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/messaging.js b/js/messaging.js index 40075974..ea21328f 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -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)) { diff --git a/manage/manage.js b/manage/manage.js index c2dbd3d4..cb24dbb9 100644 --- a/manage/manage.js +++ b/manage/manage.js @@ -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') {