Add: styleManager.setMeta
This commit is contained in:
parent
831d1b6fc3
commit
0fc73b5f8c
|
@ -79,7 +79,8 @@ const styleManager = (() => {
|
||||||
addExclusion,
|
addExclusion,
|
||||||
removeExclusion,
|
removeExclusion,
|
||||||
addInclusion,
|
addInclusion,
|
||||||
removeInclusion
|
removeInclusion,
|
||||||
|
setMeta
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleColorScheme() {
|
function handleColorScheme() {
|
||||||
|
@ -258,6 +259,18 @@ const styleManager = (() => {
|
||||||
return removeIncludeExclude(id, rule, 'inclusions');
|
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) {
|
function deleteStyle(id) {
|
||||||
const style = styles.get(id);
|
const style = styles.get(id);
|
||||||
return db.exec('delete', id)
|
return db.exec('delete', id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user