Skip to content

Commit 92790f3

Browse files
Miodecfehmer
andauthored
refactor(config): config metadata (@Miodec) (monkeytypegame#6753)
Create config metadata object Move all the special code on config change to config listeners Create a generic set function which will work with the metadata object to update any config key Update all setters to use the generic set. (Later probably only use the generic settter and remove all the specific ones) Also orders config groups and config schema. --------- Co-authored-by: Christian Fehmer <[email protected]>
1 parent db9e54f commit 92790f3

File tree

22 files changed

+1721
-1717
lines changed

22 files changed

+1721
-1717
lines changed

backend/__tests__/api/controllers/config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe("ConfigController", () => {
100100
expect(body).toStrictEqual({
101101
message: "Invalid request data schema",
102102
validationErrors: [
103-
`"autoSwitchTheme" Expected boolean, received string`,
104103
`"confidenceMode" Invalid enum value. Expected 'off' | 'on' | 'max', received 'pretty'`,
104+
`"autoSwitchTheme" Expected boolean, received string`,
105105
],
106106
});
107107

backend/__tests__/api/controllers/preset.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ describe("PresetController", () => {
249249
expect(body).toStrictEqual({
250250
message: "Invalid request data schema",
251251
validationErrors: [
252-
`"config.autoSwitchTheme" Expected boolean, received string`,
253252
`"config.confidenceMode" Invalid enum value. Expected 'off' | 'on' | 'max', received 'pretty'`,
253+
`"config.autoSwitchTheme" Expected boolean, received string`,
254254
`"config" Unrecognized key(s) in object: 'extra'`,
255255
`Unrecognized key(s) in object: '_id', 'extra'`,
256256
],
@@ -427,9 +427,9 @@ describe("PresetController", () => {
427427
expect(body).toStrictEqual({
428428
message: "Invalid request data schema",
429429
validationErrors: [
430-
`"settingGroups.0" Invalid enum value. Expected 'test' | 'behavior' | 'input' | 'sound' | 'caret' | 'appearance' | 'theme' | 'hideElements' | 'ads' | 'hidden', received 'mappers'`,
431-
`"config.autoSwitchTheme" Expected boolean, received string`,
430+
`"settingGroups.0" Invalid enum value. Expected 'test' | 'behavior' | 'input' | 'sound' | 'caret' | 'appearance' | 'theme' | 'hideElements' | 'hidden' | 'ads', received 'mappers'`,
432431
`"config.confidenceMode" Invalid enum value. Expected 'off' | 'on' | 'max', received 'pretty'`,
432+
`"config.autoSwitchTheme" Expected boolean, received string`,
433433
`"config" Unrecognized key(s) in object: 'extra'`,
434434
`Unrecognized key(s) in object: 'extra'`,
435435
],

0 commit comments

Comments
 (0)