Fix: saveUsercss

This commit is contained in:
eight 2017-09-12 18:52:55 +08:00
parent a395df18f9
commit e13a6f6f92

View File

@ -413,13 +413,7 @@ function filterUsercss(req) {
function saveUsercss(style) { function saveUsercss(style) {
// This function use `saveStyle`, however the response is different. // This function use `saveStyle`, however the response is different.
return Promise.resolve() return buildMeta()
.then(() => {
if (!style.name || !style.namespace) {
return Object.assign(usercss.buildMeta(style.source), style);
}
return style;
})
.then(saveStyle) .then(saveStyle)
.then(result => ({ .then(result => ({
status: 'success', status: 'success',
@ -429,6 +423,16 @@ function saveUsercss(style) {
status: 'error', status: 'error',
error: String(err) 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);
});
}
} }