async'ify replaceStyle
This commit is contained in:
parent
34ad3cfaef
commit
4fade0fdfe
|
@ -591,10 +591,12 @@ function createSectionsEditor(editorBase) {
|
||||||
updateSectionOrder();
|
updateSectionOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceStyle(newStyle, codeIsUpdated) {
|
async function replaceStyle(newStyle, codeIsUpdated) {
|
||||||
dirty.clear('name');
|
dirty.clear('name');
|
||||||
// FIXME: avoid recreating all editors?
|
// FIXME: avoid recreating all editors?
|
||||||
reinit().then(() => {
|
if (codeIsUpdated !== false) {
|
||||||
|
await initSections(newStyle.sections, {replace: true, pristine: true});
|
||||||
|
}
|
||||||
Object.assign(style, newStyle);
|
Object.assign(style, newStyle);
|
||||||
updateHeader();
|
updateHeader();
|
||||||
dirty.clear();
|
dirty.clear();
|
||||||
|
@ -605,13 +607,5 @@ function createSectionsEditor(editorBase) {
|
||||||
}
|
}
|
||||||
livePreview.show(Boolean(style.id));
|
livePreview.show(Boolean(style.id));
|
||||||
updateLivePreview();
|
updateLivePreview();
|
||||||
});
|
|
||||||
|
|
||||||
function reinit() {
|
|
||||||
if (codeIsUpdated !== false) {
|
|
||||||
return initSections(newStyle.sections, {replace: true, pristine: true});
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user