Add: styleManager.setMeta

This commit is contained in:
eight 2019-06-26 01:10:15 +08:00
parent 831d1b6fc3
commit 0fc73b5f8c

View File

@ -79,7 +79,8 @@ const styleManager = (() => {
addExclusion,
removeExclusion,
addInclusion,
removeInclusion
removeInclusion,
setMeta
});
function handleColorScheme() {
@ -258,6 +259,18 @@ const styleManager = (() => {
return removeIncludeExclude(id, rule, 'inclusions');
}
function setMeta(id, key, value) {
// FIXME: it is pretty danger to expose an API to modify *any* property on the data.
const oldData = styles.get(id).data;
if (oldData[key] === value) {
return;
}
const data = Object.assign({}, oldData);
data[key] = value;
return saveStyle(data)
.then(newData => handleSave(newData, 'styleSettings'));
}
function deleteStyle(id) {
const style = styles.get(id);
return db.exec('delete', id)