From e13a6f6f9254ce4633253302cea4ccb77c91825a Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 12 Sep 2017 18:52:55 +0800 Subject: [PATCH] Fix: saveUsercss --- background/storage.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/background/storage.js b/background/storage.js index ba5cd58c..72bb0828 100644 --- a/background/storage.js +++ b/background/storage.js @@ -413,13 +413,7 @@ function filterUsercss(req) { function saveUsercss(style) { // This function use `saveStyle`, however the response is different. - return Promise.resolve() - .then(() => { - if (!style.name || !style.namespace) { - return Object.assign(usercss.buildMeta(style.source), style); - } - return style; - }) + return buildMeta() .then(saveStyle) .then(result => ({ status: 'success', @@ -429,6 +423,16 @@ function saveUsercss(style) { status: 'error', error: String(err) })); + + function buildMeta() { + return new Promise(resolve => { + if (!style.name || !style.namespace) { + resolve(Object.assign(usercss.buildMeta(style.source), style)); + return; + } + resolve(style); + }); + } }