Insert missing ooba samplers

This commit is contained in:
Cohee 2024-09-28 13:56:57 +03:00
parent 8bd1c88d15
commit b1bb41313f
1 changed files with 16 additions and 0 deletions

View File

@ -805,6 +805,21 @@ function showTypeSpecificControls(type) {
});
}
/**
* Inserts missing items from the source array into the target array.
* @param {any[]} source - Source array
* @param {any[]} target - Target array
* @returns {void}
*/
function insertMissingArrayItems(source, target) {
for (const item of source) {
if (!target.includes(item)) {
const index = source.indexOf(item);
target.splice(index, 0, item);
}
}
}
function setSettingByName(setting, value, trigger) {
if (value === null || value === undefined) {
return;
@ -819,6 +834,7 @@ function setSettingByName(setting, value, trigger) {
if ('sampler_priority' === setting) {
value = Array.isArray(value) ? value : OOBA_DEFAULT_ORDER;
insertMissingArrayItems(OOBA_DEFAULT_ORDER, value);
sortOobaItemsByOrder(value);
settings.sampler_priority = value;
return;