correctly setting the current model in the special prompts pages

This commit is contained in:
Mic 2026-03-25 00:13:00 +01:00
parent b7f3b15b2a
commit 021e317a37
5 changed files with 68 additions and 54 deletions

View file

@ -330,19 +330,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -227,19 +227,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -180,19 +180,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -322,17 +322,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Ensure option exists before restoring
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -30,7 +30,8 @@ import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js
import {
getAccountsList,
normalizeStringList,
isAPIKeyValue
isAPIKeyValue,
setTomSelectBorder
} from "../../js/mzta-utils.js";
import {
initializeSpecificIntegrationUI
@ -235,18 +236,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: String(restoreValue), text: String(restoreValue) });
}
element.tomselect.setValue(String(restoreValue), true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);