async'ify replaceStyle
This commit is contained in:
parent
34ad3cfaef
commit
4fade0fdfe
|
@ -591,27 +591,21 @@ 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) {
|
||||||
Object.assign(style, newStyle);
|
await initSections(newStyle.sections, {replace: true, pristine: true});
|
||||||
updateHeader();
|
|
||||||
dirty.clear();
|
|
||||||
// Go from new style URL to edit style URL
|
|
||||||
if (location.href.indexOf('id=') === -1 && style.id) {
|
|
||||||
history.replaceState({}, document.title, 'edit.html?id=' + style.id);
|
|
||||||
$('#heading').textContent = t('editStyleHeading');
|
|
||||||
}
|
|
||||||
livePreview.show(Boolean(style.id));
|
|
||||||
updateLivePreview();
|
|
||||||
});
|
|
||||||
|
|
||||||
function reinit() {
|
|
||||||
if (codeIsUpdated !== false) {
|
|
||||||
return initSections(newStyle.sections, {replace: true, pristine: true});
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
Object.assign(style, newStyle);
|
||||||
|
updateHeader();
|
||||||
|
dirty.clear();
|
||||||
|
// Go from new style URL to edit style URL
|
||||||
|
if (location.href.indexOf('id=') === -1 && style.id) {
|
||||||
|
history.replaceState({}, document.title, 'edit.html?id=' + style.id);
|
||||||
|
$('#heading').textContent = t('editStyleHeading');
|
||||||
|
}
|
||||||
|
livePreview.show(Boolean(style.id));
|
||||||
|
updateLivePreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user