clear dirty upon swapping style

This commit is contained in:
tophf 2020-10-22 23:31:09 +03:00
parent 0199b2c0bb
commit 2d9785be6e

View File

@ -48,7 +48,7 @@ function createSectionsEditor(editorBase) {
let sectionOrder = ''; let sectionOrder = '';
let headerOffset; // in compact mode the header is at the top so it reduces the available height let headerOffset; // in compact mode the header is at the top so it reduces the available height
const ready = initSections(style.sections.slice(), {isFirstInit: true}); const ready = initSections(style.sections, {isFirstInit: true});
const livePreview = createLivePreview(); const livePreview = createLivePreview();
livePreview.show(Boolean(style.id)); livePreview.show(Boolean(style.id));
@ -455,6 +455,7 @@ function createSectionsEditor(editorBase) {
} = {}) { } = {}) {
let done; let done;
const total = originalSections.length; const total = originalSections.length;
originalSections = originalSections.slice();
return new Promise(resolve => { return new Promise(resolve => {
done = resolve; done = resolve;
chunk(true); chunk(true);
@ -571,13 +572,13 @@ function createSectionsEditor(editorBase) {
updateSectionOrder(); updateSectionOrder();
} }
function replaceSections(originalSections) { function replaceSections(...args) {
for (const section of sections) { for (const section of sections) {
section.remove(true); section.remove(true);
} }
sections.length = 0; sections.length = 0;
container.textContent = ''; container.textContent = '';
return initSections(originalSections); return initSections(...args);
} }
function replaceStyle(newStyle, codeIsUpdated) { function replaceStyle(newStyle, codeIsUpdated) {
@ -598,7 +599,7 @@ function createSectionsEditor(editorBase) {
function reinit() { function reinit() {
if (codeIsUpdated !== false) { if (codeIsUpdated !== false) {
return replaceSections(newStyle.sections.slice()); return replaceSections(newStyle.sections, {isFirstInit: true});
} }
return Promise.resolve(); return Promise.resolve();
} }