Settings: Cache default value

This commit is contained in:
Vendicated 2022-10-26 14:28:27 +02:00
parent 670b7d7d01
commit b87f0bf3f9
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -76,9 +76,13 @@ function makeProxy(settings: Settings, root = settings, path = ""): Settings {
if (!setting) return v; if (!setting) return v;
if ("default" in setting) if ("default" in setting)
// normal setting with a default value // normal setting with a default value
return setting.default; return (target[p] = setting.default);
if (setting.type === OptionType.SELECT) if (setting.type === OptionType.SELECT) {
return setting.options.find(o => o.default)?.value; const def = setting.options.find(o => o.default);
if (def)
target[p] = def.value;
return def?.value;
}
} }
} }
return v; return v;