Skip to content

Commit

Permalink
Fix no previewer for no-code demos
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Nov 18, 2023
1 parent 66977e6 commit d1c89e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Previewer/Previewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default function Previewer({
if (settings.get_boolean("auto-preview")) schedule_update();
});
let symbols = null;
async function update(force = false) {
async function update(force = false, clearConsole = true) {
if (!(force || settings.get_boolean("auto-preview"))) return;
let text = panel_ui.xml.trim();
let target_id;
Expand Down Expand Up @@ -203,7 +203,9 @@ export default function Previewer({

registerSignals({ tree, scope, symbols, template });

term_console.clear();
if (clearConsole) {
term_console.clear();
}

try {
builder.add_from_string(text, -1);
Expand Down
5 changes: 3 additions & 2 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ export default function Window({ application, session }) {

previewer.start();
panel_ui.start();
// We already cleared the console before starting.
// We don't want to clear the console again, as this would hide compile errors if any occurred.
await previewer.update(true, false);

button_run.set_sensitive(true);
term_console.scrollToEnd();
Expand All @@ -345,8 +348,6 @@ export default function Window({ application, session }) {
}

if (language === "JavaScript") {
await previewer.update(true);

// We have to create a new file each time
// because gjs doesn't appear to use etag for module caching
// ?foo=Date.now() also does not work as expected
Expand Down

0 comments on commit d1c89e0

Please sign in to comment.