From a4259dead1cc0c22c78e2d6ee80a65abeeb5d7ff Mon Sep 17 00:00:00 2001 From: Pascal Date: Tue, 7 Jan 2025 15:39:26 +0100 Subject: [PATCH] no_reload_process --- src/pages/process/process.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/process/process.ts b/src/pages/process/process.ts index f645d6c..a051269 100755 --- a/src/pages/process/process.ts +++ b/src/pages/process/process.ts @@ -36,9 +36,8 @@ export async function init() { search_div.appendChild(autocomplete_list); search_div.appendChild(dropdown_icon); - await createMessagingProcess(); - const processes = await getProcesses(); + for (const {key, value} of processes) { const processName = await getDescription(key, value); if (processName) { @@ -49,6 +48,26 @@ export async function init() { element.add(opt); } } + const { autocomplete_options } = getOptions(element); + + if (autocomplete_options.length === 0) { + console.log('No existing processes - creating new messaging process'); + await createMessagingProcess(); + + const updatedProcesses = await getProcesses(); + for (const {key, value} of updatedProcesses) { + const processName = await getDescription(key, value); + if (processName) { + console.log('adding new process to list:', processName); + const opt = new Option(processName); + opt.value = processName; + opt.setAttribute('data-process-id', key); + element.add(opt); + } + } + } else { + console.log('Existing processes found - skipping messaging creation'); + } // set the wrapper as child (instead of the element) element.parentNode?.replaceChild(wrapper, element);