Fix: popup doesn't use getStyle/getStylesByUrl correctly

This commit is contained in:
eight 2018-10-16 23:47:42 +08:00
parent cdc922dc9b
commit 3acdf8fea7
2 changed files with 6 additions and 3 deletions

View File

@ -138,20 +138,23 @@ const styleManager = (() => {
.then(newData => handleSave(newData, 'import'));
}
function installStyle(data) {
function installStyle(data, reason = null) {
const style = styles.get(data.id);
if (!style) {
data = Object.assign(createNewStyle(), data);
} else {
data = Object.assign({}, style.data, data);
}
if (!reason) {
reason = style ? 'update' : 'install';
}
// FIXME: update updateDate? what about usercss config?
return calcStyleDigest(data)
.then(digest => {
data.originalDigest = digest;
return saveStyle(data);
})
.then(newData => handleSave(newData, style ? 'update' : 'install'));
.then(newData => handleSave(newData, reason));
}
function editSave(data) {

View File

@ -490,7 +490,7 @@ function handleUpdate({style, reason}) {
return Promise.resolve(style);
}
return API.getStylesByUrl(tabURL, style.id)
.then(([style]) => style);
.then(([result]) => result && Object.assign(result.data, result));
}
}