From 2912a53729565083854100f08f70a157e1237587 Mon Sep 17 00:00:00 2001 From: eight Date: Wed, 4 Oct 2017 16:19:20 +0800 Subject: [PATCH] Fix: missing id when updating digest --- background/update.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/background/update.js b/background/update.js index 648fa3cb..d9bfd4be 100644 --- a/background/update.js +++ b/background/update.js @@ -127,19 +127,20 @@ var updater = { if (!styleJSONseemsValid(json)) { return Promise.reject(updater.ERROR_JSON); } - if (styleSectionsEqual(json, style)) { - // JSONs may have different order of items even if sections are effectively equal - // so we'll update the digest anyway - saveStyle(Object.assign(json, {reason: 'update-digest'})); - return Promise.reject(updater.SAME_CODE); - } else if (!style.originalDigest && !ignoreDigest) { - return Promise.reject(updater.MAYBE_EDITED); - } return json; } function maybeSave(json) { json.id = style.id; + if (styleSectionsEqual(json, style)) { + // JSONs may have different order of items even if sections are effectively equal + // so we'll update the digest anyway + // always update digest even if (save === false) + saveStyle(Object.assign(json, {reason: 'update-digest'})); + return Promise.reject(updater.SAME_CODE); + } else if (!style.originalDigest && !ignoreDigest) { + return Promise.reject(updater.MAYBE_EDITED); + } if (!save) { return json; }