Skip to content

Commit 0f61225

Browse files
committed
fix(presets): missing config group definitions breaking partial presets
1 parent 09eda18 commit 0f61225

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

frontend/src/ts/modals/edit-preset.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ async function apply(): Promise<void> {
342342
Loader.hide();
343343
}
344344

345-
function getSettingGroup(configFieldName: string): PresetSettingGroup {
345+
function getSettingGroup(configFieldName: string): PresetSettingGroup | null {
346346
const themeSettings = [
347347
"theme",
348348
"themeLight",
@@ -421,6 +421,7 @@ function getSettingGroup(configFieldName: string): PresetSettingGroup {
421421
"startGraphsAtZero",
422422
"highlightMode",
423423
"tapeMode",
424+
"tapeMargin",
424425
"typingSpeedUnit",
425426
"maxLineWidth",
426427
];
@@ -435,6 +436,7 @@ function getSettingGroup(configFieldName: string): PresetSettingGroup {
435436
"strictSpace",
436437
"oppositeShiftMode",
437438
"lazyMode",
439+
"codeUnindentOnBackspace",
438440
];
439441
const soundSettings = ["playSoundOnError", "playSoundOnClick", "soundVolume"];
440442
const hiddenSettings = ["accountChart", "monkey", "monkeyPowerLevel"];
@@ -462,18 +464,23 @@ function getSettingGroup(configFieldName: string): PresetSettingGroup {
462464
return "ads";
463465
}
464466

465-
throw new Error(`${configFieldName} setting not part of any setting group`);
467+
Notifications.add(
468+
`Setting group not found for setting ${configFieldName} - it will not be saved. Please report this.`,
469+
-1
470+
);
471+
return null;
466472
}
467473

468474
function getPartialConfigChanges(
469475
configChanges: Partial<ConfigType>
470476
): Partial<ConfigType> {
471477
const activeConfigChanges: Partial<ConfigType> = {};
472478
Object.keys(defaultConfig)
473-
.filter(
474-
(settingName) =>
475-
state.checkboxes.get(getSettingGroup(settingName)) === true
476-
)
479+
.filter((settingName) => {
480+
const group = getSettingGroup(settingName);
481+
if (group === null) return false;
482+
return state.checkboxes.get(group) === true;
483+
})
477484
.forEach((settingName) => {
478485
const safeSettingName = settingName as keyof Partial<ConfigType>;
479486
const newValue =

0 commit comments

Comments
 (0)