From 2d9785be6e3cdff0f5d1285daa6ded069092fc98 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 22 Oct 2020 23:31:09 +0300 Subject: [PATCH] clear `dirty` upon swapping style --- edit/sections-editor.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/edit/sections-editor.js b/edit/sections-editor.js index dc7dd6b6..e2e3678d 100644 --- a/edit/sections-editor.js +++ b/edit/sections-editor.js @@ -48,7 +48,7 @@ function createSectionsEditor(editorBase) { let sectionOrder = ''; 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(); livePreview.show(Boolean(style.id)); @@ -455,6 +455,7 @@ function createSectionsEditor(editorBase) { } = {}) { let done; const total = originalSections.length; + originalSections = originalSections.slice(); return new Promise(resolve => { done = resolve; chunk(true); @@ -571,13 +572,13 @@ function createSectionsEditor(editorBase) { updateSectionOrder(); } - function replaceSections(originalSections) { + function replaceSections(...args) { for (const section of sections) { section.remove(true); } sections.length = 0; container.textContent = ''; - return initSections(originalSections); + return initSections(...args); } function replaceStyle(newStyle, codeIsUpdated) { @@ -598,7 +599,7 @@ function createSectionsEditor(editorBase) { function reinit() { if (codeIsUpdated !== false) { - return replaceSections(newStyle.sections.slice()); + return replaceSections(newStyle.sections, {isFirstInit: true}); } return Promise.resolve(); }