Fix: popup doesn't use getStyle/getStylesByUrl correctly
This commit is contained in:
parent
cdc922dc9b
commit
3acdf8fea7
|
@ -138,20 +138,23 @@ const styleManager = (() => {
|
||||||
.then(newData => handleSave(newData, 'import'));
|
.then(newData => handleSave(newData, 'import'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function installStyle(data) {
|
function installStyle(data, reason = null) {
|
||||||
const style = styles.get(data.id);
|
const style = styles.get(data.id);
|
||||||
if (!style) {
|
if (!style) {
|
||||||
data = Object.assign(createNewStyle(), data);
|
data = Object.assign(createNewStyle(), data);
|
||||||
} else {
|
} else {
|
||||||
data = Object.assign({}, style.data, data);
|
data = Object.assign({}, style.data, data);
|
||||||
}
|
}
|
||||||
|
if (!reason) {
|
||||||
|
reason = style ? 'update' : 'install';
|
||||||
|
}
|
||||||
// FIXME: update updateDate? what about usercss config?
|
// FIXME: update updateDate? what about usercss config?
|
||||||
return calcStyleDigest(data)
|
return calcStyleDigest(data)
|
||||||
.then(digest => {
|
.then(digest => {
|
||||||
data.originalDigest = digest;
|
data.originalDigest = digest;
|
||||||
return saveStyle(data);
|
return saveStyle(data);
|
||||||
})
|
})
|
||||||
.then(newData => handleSave(newData, style ? 'update' : 'install'));
|
.then(newData => handleSave(newData, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
function editSave(data) {
|
function editSave(data) {
|
||||||
|
|
|
@ -490,7 +490,7 @@ function handleUpdate({style, reason}) {
|
||||||
return Promise.resolve(style);
|
return Promise.resolve(style);
|
||||||
}
|
}
|
||||||
return API.getStylesByUrl(tabURL, style.id)
|
return API.getStylesByUrl(tabURL, style.id)
|
||||||
.then(([style]) => style);
|
.then(([result]) => result && Object.assign(result.data, result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user