no_reload_process

This commit is contained in:
Pascal 2025-01-07 15:39:26 +01:00
parent 572d83b506
commit a4259dead1

View File

@ -36,9 +36,8 @@ export async function init() {
search_div.appendChild(autocomplete_list); search_div.appendChild(autocomplete_list);
search_div.appendChild(dropdown_icon); search_div.appendChild(dropdown_icon);
await createMessagingProcess();
const processes = await getProcesses(); const processes = await getProcesses();
for (const {key, value} of processes) { for (const {key, value} of processes) {
const processName = await getDescription(key, value); const processName = await getDescription(key, value);
if (processName) { if (processName) {
@ -49,6 +48,26 @@ export async function init() {
element.add(opt); 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) // set the wrapper as child (instead of the element)
element.parentNode?.replaceChild(wrapper, element); element.parentNode?.replaceChild(wrapper, element);