Fix: toggle style outside of the editor

This commit is contained in:
eight 2017-10-15 04:14:57 +08:00
parent 9770523660
commit 96a046f774
2 changed files with 3 additions and 12 deletions

View File

@ -1909,7 +1909,8 @@ function getParams() {
chrome.runtime.onMessage.addListener(onRuntimeMessage); chrome.runtime.onMessage.addListener(onRuntimeMessage);
function replaceStyle(request) { function replaceStyle(request) {
if (!isClean() && !confirm(t('styleUpdateDiscardChanges'))) { const codeIsUpdated = request.codeIsUpdated !== false;
if (!isClean() && (!codeIsUpdated || !confirm(t('styleUpdateDiscardChanges')))) {
return; return;
} }
@ -1918,11 +1919,7 @@ function replaceStyle(request) {
return; return;
} }
if (request.codeIsUpdated === false) { editor.replaceStyle(request.style, codeIsUpdated);
editor.updateStyleMeta(request.style);
} else {
editor.replaceStyle(request.style);
}
} }
function onRuntimeMessage(request) { function onRuntimeMessage(request) {

View File

@ -609,11 +609,6 @@ ${section}
dirty.clear(); dirty.clear();
} }
function updateStyleMeta(newStyle) {
dirty.modify('enabled', style.enabled, newStyle.enabled);
style.enabled = newStyle.enabled;
}
function toggleStyle() { function toggleStyle() {
const value = !style.enabled; const value = !style.enabled;
dirty.modify('enabled', style.enabled, value); dirty.modify('enabled', style.enabled, value);
@ -645,7 +640,6 @@ ${section}
replaceStyle, replaceStyle,
save, save,
toggleStyle, toggleStyle,
updateStyleMeta,
isDirty: dirty.isDirty, isDirty: dirty.isDirty,
getStyle: () => style getStyle: () => style
}; };