Fix: make codeIsUpdated flag work properly

This commit is contained in:
eight 2017-09-12 19:57:43 +08:00
parent e7eb38bba9
commit 4b2f7a1a46
2 changed files with 16 additions and 7 deletions

View File

@ -1365,17 +1365,21 @@ function setStyleMeta(style) {
$('#url').href = style.url || ''; $('#url').href = style.url || '';
} }
function initWithStyle({style}) { function initWithStyle(request) {
// FIXME: what does codeIsUpdated do?
if (!style.usercss) { if (!style.usercss) {
initWithSectionStyle({style}); initWithSectionStyle(request);
return; return;
} }
if (editor) { if (!editor) {
editor.replaceStyle(style); editor = createSourceEditor(request.style);
return;
}
if (request.codeIsUpdated === false) {
editor.updateStyleMeta(request.style);
} else { } else {
editor = createSourceEditor(style); editor.replaceStyle(request.style);
} }
} }

View File

@ -95,6 +95,11 @@ function createSourceEditor(style) {
dirty.clear(); dirty.clear();
} }
function updateStyleMeta(_style) {
dirty.modify('enabled', style.enabled, _style.enabled);
style.enabled = _style.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);
@ -132,5 +137,5 @@ function createSourceEditor(style) {
}); });
} }
return {replaceStyle, save, toggleStyle}; return {replaceStyle, save, toggleStyle, updateStyleMeta};
} }