From 7c58c3cd0c3092caed4d86280e41f638014db7b7 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 16 Apr 2023 00:40:54 +0200 Subject: [PATCH] fix refreshFlow loop --- backend/tests/worker.rs | 1 + .../inlineScriptsPanel/InlineScriptEditorPanel.svelte | 11 +++++++---- frontend/src/lib/scripts.ts | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index f8d8edd6b5..e5601a654b 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -2452,6 +2452,7 @@ async fn test_flow_lock_all(db: Pool) { .modules .into_iter() .for_each(|m| { + tracing::error!("Module: {:?}", m.value); assert!(matches!( m.value, windmill_api_client::types::FlowModuleValue::Rawscript { diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte index c3ac757602..21dbb400b4 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte @@ -67,12 +67,15 @@ } async function refreshFlow(x: RunnableByPath) { - const schema = (await loadSchema($workspaceStore ?? '', x.path, 'flow')) ?? emptySchema() - x.schema = schema if (componentInput?.type == 'runnable') { - componentInput.fields = computeFields(schema, false, componentInput.fields) + const schema = (await loadSchema($workspaceStore ?? '', x.path, 'flow')) ?? emptySchema() + x.schema = schema + const nfields = computeFields(schema, false, componentInput.fields) + if (!deepEqual(componentInput.fields, nfields)) { + componentInput.fields = nfields + componentInput = componentInput + } } - componentInput = componentInput } $: if ( componentInput && diff --git a/frontend/src/lib/scripts.ts b/frontend/src/lib/scripts.ts index 41c152ca18..9a8d38316b 100644 --- a/frontend/src/lib/scripts.ts +++ b/frontend/src/lib/scripts.ts @@ -30,12 +30,10 @@ export async function loadSchema(path: string, hash?: string): Promise { } } - export async function loadSchemaFlow(path: string): Promise { const flow = await FlowService.getFlowByPath({ workspace: get(workspaceStore)!, path: path ?? '' }) return flow.schema - }