no_reload_process

This commit is contained in:
Pascal 2025-01-07 15:39:26 +01:00 committed by NicolasCantu
parent 195205e8df
commit 6d5d0172c0

View File

@ -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);