Fix: replaceStyle make style name undefined
This commit is contained in:
parent
fa080d1913
commit
8016346035
14
edit/edit.js
14
edit/edit.js
|
@ -325,14 +325,12 @@ function onRuntimeMessage(request) {
|
||||||
request.reason !== 'editPreview' &&
|
request.reason !== 'editPreview' &&
|
||||||
request.reason !== 'editSave' &&
|
request.reason !== 'editSave' &&
|
||||||
request.reason !== 'config') {
|
request.reason !== 'config') {
|
||||||
// code-less style from notifyAllTabs
|
Promise.resolve(request.codeIsUpdated === false ?
|
||||||
const {sections, id} = request.style;
|
request.style : API.getStyle(request.style.id)
|
||||||
((sections && sections[0] || {}).code === null
|
)
|
||||||
? API.getStyle(id)
|
.then(newStyle => {
|
||||||
: Promise.resolve([request.style])
|
editor.replaceStyle(newStyle, request.codeIsUpdated);
|
||||||
).then(([style]) => {
|
});
|
||||||
editor.replaceStyle(style, request.codeIsUpdated);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'styleDeleted':
|
case 'styleDeleted':
|
||||||
|
|
|
@ -942,7 +942,7 @@ function createSectionsEditor(style) {
|
||||||
function replaceStyle(newStyle, codeIsUpdated) {
|
function replaceStyle(newStyle, codeIsUpdated) {
|
||||||
// FIXME: avoid recreating all editors?
|
// FIXME: avoid recreating all editors?
|
||||||
reinit().then(() => {
|
reinit().then(() => {
|
||||||
style = newStyle;
|
Object.assign(style, newStyle);
|
||||||
updateHeader();
|
updateHeader();
|
||||||
dirty.clear();
|
dirty.clear();
|
||||||
// Go from new style URL to edit style URL
|
// Go from new style URL to edit style URL
|
||||||
|
|
|
@ -216,7 +216,7 @@ function createSourceEditor(style) {
|
||||||
history.replaceState({}, '', `?id=${newStyle.id}`);
|
history.replaceState({}, '', `?id=${newStyle.id}`);
|
||||||
}
|
}
|
||||||
sessionStorage.justEditedStyleId = newStyle.id;
|
sessionStorage.justEditedStyleId = newStyle.id;
|
||||||
style = newStyle;
|
Object.assign(style, newStyle);
|
||||||
$('#preview-label').classList.remove('hidden');
|
$('#preview-label').classList.remove('hidden');
|
||||||
updateMeta();
|
updateMeta();
|
||||||
livePreview.show(Boolean(style.id));
|
livePreview.show(Boolean(style.id));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user