Formalize the to/from Store rules for UserStore (#2708)

- Explicitly don't save to disk if the value in the store is the same as
  the default. That way we can change the defaults between versions

- Calculate the PreferencesModel on demand

- In the future, when we turn on strict null checking, we can enforce
  that the UserStore expects the correct types too

Signed-off-by: Sebastian Malton <sebastian@malton.name>

simplify default check, remove defaults from UserStore

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-07-06 09:14:13 -04:00
1 parent baef6944aa
commit c4623c424d
5 files changed
+315 -99

No files matched your search

+3 -2
View File
@@ -41,6 +41,7 @@ import { SemVer } from "semver";
import electron from "electron";
import { stdout, stderr } from "process";
import { beforeEachWrapped } from "../../../integration/helpers/utils";
import { ThemeStore } from "../../renderer/theme.store";
console = new Console(stdout, stderr);
@@ -72,7 +73,7 @@ describe("user store tests", () => {
us.httpsProxy = "abcd://defg";
expect(us.httpsProxy).toBe("abcd://defg");
expect(us.colorTheme).toBe(UserStore.defaultTheme);
expect(us.colorTheme).toBe(ThemeStore.defaultTheme);
us.colorTheme = "light";
expect(us.colorTheme).toBe("light");
@@ -83,7 +84,7 @@ describe("user store tests", () => {
us.colorTheme = "some other theme";
us.resetTheme();
expect(us.colorTheme).toBe(UserStore.defaultTheme);
expect(us.colorTheme).toBe(ThemeStore.defaultTheme);
});
it("correctly calculates if the last seen version is an old release", () => {