From b87f0bf3f96dce3c51f0b571e55d5d131af1d3f2 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 26 Oct 2022 14:28:27 +0200 Subject: [PATCH] Settings: Cache default value --- src/api/settings.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api/settings.ts b/src/api/settings.ts index 5d581c63..e25572f3 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -76,9 +76,13 @@ function makeProxy(settings: Settings, root = settings, path = ""): Settings { if (!setting) return v; if ("default" in setting) // normal setting with a default value - return setting.default; - if (setting.type === OptionType.SELECT) - return setting.options.find(o => o.default)?.value; + return (target[p] = setting.default); + if (setting.type === OptionType.SELECT) { + const def = setting.options.find(o => o.default); + if (def) + target[p] = def.value; + return def?.value; + } } } return v;