fix: custom min speed mode setting not saving between sessions

closes #6890
This commit is contained in:
Miodec 2025-08-18 15:13:24 +02:00
parent 6f50752b69
commit 14ce657273
2 changed files with 31 additions and 2 deletions

View file

@ -157,7 +157,7 @@ describe("Config", () => {
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
"stopOnError",
"off",
true,
false,
"letter"
);
@ -195,6 +195,35 @@ describe("Config", () => {
expect.stringContaining("numbers")
);
});
it("saves configOverride values to localstorage if nosave=false", async () => {
//GIVEN
replaceConfig({});
//WHEN
Config.genericSet("minWpmCustomSpeed", 120);
//THEN
//wait for debounce
await vi.advanceTimersByTimeAsync(2500);
//save
expect(dbSaveConfigMock).toHaveBeenCalledWith({
minWpmCustomSpeed: 120,
minWpm: "custom",
});
//send event
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
"saveToLocalStorage",
expect.stringContaining("minWpmCustomSpeed")
);
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
"saveToLocalStorage",
expect.stringContaining("minWpm")
);
});
it("does not save to localstorage if nosave=true", async () => {
//GIVEN

View file

@ -175,7 +175,7 @@ export function genericSet<T extends keyof ConfigSchemas.Config>(
continue; // no need to set if the value is already the same
}
const set = genericSet(targetKey, targetValue, true);
const set = genericSet(targetKey, targetValue, nosave);
if (!set) {
throw new Error(
`Failed to set config key "${targetKey}" with value "${targetValue}" for ${metadata.displayString} config override.`