Add: make filterUsercss build code to get section includes

This commit is contained in:
eight 2017-09-05 10:31:24 +08:00
parent 78264a1c34
commit f74641e20d

View File

@ -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)}));
}