From 487bc77baa2a9d9f813d84214a47e2c09617ea9e Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 24 Dec 2017 01:50:53 +0300 Subject: [PATCH] actually replace 'usercssTemplate' --- edit/source-editor.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/edit/source-editor.js b/edit/source-editor.js index da42c394..1bdd2f4d 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -214,25 +214,22 @@ function createSourceEditor(style) { if (!dirty.isDirty()) { return; } + const code = cm.getValue(); return onBackgroundReady() .then(() => BG.usercssHelper.save({ reason: 'editSave', id: style.id, enabled: style.enabled, - sourceCode: cm.getValue(), + sourceCode: code, })) .then(replaceStyle) .then(() => cm.setOption('mode', cm.doc.mode)) .catch(err => { if (err.message === t('styleMissingMeta', 'name')) { messageBox.confirm(t('usercssReplaceTemplateConfirmation')).then(ok => ok && - BG.chromeSync.setLZValue('usercssTemplate', style.sourceCode) + BG.chromeSync.setLZValue('usercssTemplate', code) .then(() => BG.chromeSync.getLZValue('usercssTemplate')) - .then(saved => { - if (saved !== style.sourceCode) { - messageBox.alert(t('syncStorageErrorSaving')); - } - })); + .then(saved => saved !== code && messageBox.alert(t('syncStorageErrorSaving')))); return; } const contents = Array.isArray(err) ?