update refreshAllTabs cache and icon on disabling livepreview

This commit is contained in:
tophf 2018-01-14 17:30:06 +03:00
parent 823926a025
commit 72e0f5fbf5

View File

@ -47,6 +47,11 @@ global updateIcon
if (!style) {
msg = {method: 'styleReplaceAll'};
// live preview puts the code in cachedStyles, saves the original in previewFromTabs,
// and if preview is being disabled, but the style is already deleted, we bail out
} else if (msg.reason === 'editPreview' && !updateCache(msg)) {
return;
// simple style update:
// * if disabled, apply.js will remove the element
// * if toggled and code is unchanged, apply.js will toggle the element
@ -61,11 +66,6 @@ global updateIcon
codeIsUpdated,
};
// live preview puts the code in cachedStyles, saves the original in previewFromTabs,
// and if preview is being disabled, but the style is already deleted, we bail out
} else if (msg.reason === 'editPreview' && !updateCache(msg)) {
return;
// live preview normal operation, the new code is already in cachedStyles
} else {
msg.method = 'styleApply';
@ -127,10 +127,10 @@ global updateIcon
invokeOrPostpone(tab.active, sendMessage, msg, ignoreChromeError);
}
if (msg.method === 'styleReplaceAll' && !frame.frameId) {
if (!frame.frameId) {
setTimeout(updateIcon, 0, {
tab,
styles,
styles: msg.method === 'styleReplaceAll' ? styles : undefined,
});
}
}