From f74641e20d32388f47f7e3dce6a37d0d31259e48 Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 5 Sep 2017 10:31:24 +0800 Subject: [PATCH] Add: make filterUsercss build code to get section includes --- background/storage.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/background/storage.js b/background/storage.js index 54ac566f..3249eb6c 100644 --- a/background/storage.js +++ b/background/storage.js @@ -274,11 +274,17 @@ function filterUsercss(req) { if (!style.id && req.id) { style.id = req.id; } - if (!style.id && req.checkDup) { - return findDupUsercss(style) - .then(dup => ({status: 'success', style, dup})); + let pending; + if (!style.sections || !style.sections.length) { + pending = usercss.buildCode(style); + } else { + pending = Promise.resolve(style); } - return {status: 'success', style}; + if (!style.id && req.checkDup) { + return Promise.all([pending, findDupUsercss(style)]) + .then(([, dup]) => ({status: 'success', style, dup})); + } + return pending.then(() => ({status: 'success', style})); }).catch(err => ({status: 'error', error: String(err)})); }