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);
function replaceStyle(request) {
if (!isClean() && !confirm(t('styleUpdateDiscardChanges'))) {
const codeIsUpdated = request.codeIsUpdated !== false;
if (!isClean() && (!codeIsUpdated || !confirm(t('styleUpdateDiscardChanges')))) {
return;
}
@ -1918,11 +1919,7 @@ function replaceStyle(request) {
return;
}
if (request.codeIsUpdated === false) {
editor.updateStyleMeta(request.style);
} else {
editor.replaceStyle(request.style);
}
editor.replaceStyle(request.style, codeIsUpdated);
}
function onRuntimeMessage(request) {

View File

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