From 96a046f7742cd40b5fa17f51a4e175892f834694 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 15 Oct 2017 04:14:57 +0800 Subject: [PATCH] Fix: toggle style outside of the editor --- edit/edit.js | 9 +++------ edit/source-editor.js | 6 ------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index 3d06a20d..ded0713f 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -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) { diff --git a/edit/source-editor.js b/edit/source-editor.js index 114af0bf..3d124912 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -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 };