Restore implicit handleUpdate in saveStyle
This commit is contained in:
parent
a6c3424b53
commit
8bcd7f60c5
|
@ -85,8 +85,10 @@ function importFromString(jsonString) {
|
|||
stats.unchanged.ids.push(oldStyle.id);
|
||||
continue;
|
||||
}
|
||||
saveStyle(item, {notify: false}).then(style => {
|
||||
handleUpdate(style, {reason: 'import'});
|
||||
saveStyle(Object.assign(item, {
|
||||
reason: 'import',
|
||||
notify: false,
|
||||
})).then(style => {
|
||||
setTimeout(proceed, 0, resolve);
|
||||
if (!oldStyle) {
|
||||
stats.added.names.push(style.name);
|
||||
|
@ -160,11 +162,12 @@ function importFromString(jsonString) {
|
|||
}
|
||||
const id = newIds[index++];
|
||||
deleteStyle(id, {notify: false}).then(id => {
|
||||
handleDelete(id);
|
||||
const oldStyle = oldStylesById.get(id);
|
||||
if (oldStyle) {
|
||||
saveStyle(Object.assign(oldStyle, {reason: 'undoImport'}), {notify: false})
|
||||
.then(handleUpdate)
|
||||
saveStyle(Object.assign(oldStyle, {
|
||||
reason: 'undoImport',
|
||||
notify: false,
|
||||
}))
|
||||
.then(() => setTimeout(undoNextId, 0, resolve));
|
||||
} else {
|
||||
setTimeout(undoNextId, 0, resolve);
|
||||
|
|
13
manage.js
13
manage.js
|
@ -215,14 +215,13 @@ class EntryOnClick {
|
|||
}
|
||||
|
||||
static update(event) {
|
||||
const element = getClickedStyleElement(event);
|
||||
const updatedCode = element.updatedCode;
|
||||
const updatedCode = getClickedStyleElement(event).updatedCode;
|
||||
// update everything but name
|
||||
delete updatedCode.name;
|
||||
updatedCode.id = element.styleId;
|
||||
updatedCode.reason = 'update';
|
||||
saveStyle(updatedCode)
|
||||
.then(style => handleUpdate(style, {reason: 'update'}));
|
||||
saveStyle(Object.assign(updatedCode, {
|
||||
id: element.styleId,
|
||||
name: null,
|
||||
reason: 'update',
|
||||
}));
|
||||
}
|
||||
|
||||
static delete(event) {
|
||||
|
|
16
storage.js
16
storage.js
|
@ -250,7 +250,7 @@ function cleanupCachedFilters({force = false} = {}) {
|
|||
}
|
||||
|
||||
|
||||
function saveStyle(style, {notify = true} = {}) {
|
||||
function saveStyle(style) {
|
||||
return new Promise(resolve => {
|
||||
getDatabase(db => {
|
||||
const tx = db.transaction(['styles'], 'readwrite');
|
||||
|
@ -258,8 +258,13 @@ function saveStyle(style, {notify = true} = {}) {
|
|||
|
||||
const id = style.id !== undefined && style.id !== null ? Number(style.id) : null;
|
||||
const reason = style.reason;
|
||||
const notify = style.notify !== false;
|
||||
delete style.method;
|
||||
delete style.reason;
|
||||
delete style.notify;
|
||||
if (!style.name) {
|
||||
delete style.name;
|
||||
}
|
||||
|
||||
// Update
|
||||
if (id != null) {
|
||||
|
@ -279,6 +284,9 @@ function saveStyle(style, {notify = true} = {}) {
|
|||
style, codeIsUpdated, reason,
|
||||
});
|
||||
}
|
||||
if (typeof handleUpdate != 'undefined') {
|
||||
handleUpdate(style, {reason});
|
||||
}
|
||||
resolve(style);
|
||||
};
|
||||
};
|
||||
|
@ -303,6 +311,9 @@ function saveStyle(style, {notify = true} = {}) {
|
|||
if (notify) {
|
||||
notifyAllTabs({method: 'styleAdded', style, reason});
|
||||
}
|
||||
if (typeof handleUpdate != 'undefined') {
|
||||
handleUpdate(style, {reason});
|
||||
}
|
||||
resolve(style);
|
||||
};
|
||||
});
|
||||
|
@ -336,6 +347,9 @@ function deleteStyle(id, {notify = true} = {}) {
|
|||
invalidateCache(notify, {deletedId: id});
|
||||
if (notify) {
|
||||
notifyAllTabs({method: 'styleDeleted', id});
|
||||
}
|
||||
if (typeof handleDelete != 'undefined') {
|
||||
handleDelete(id);
|
||||
}
|
||||
resolve(id);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user