diff options
author | 2022-01-28 01:07:56 +0100 | |
---|---|---|
committer | 2022-02-08 21:43:18 +0100 | |
commit | 24bbe1f574ee6b0d6d0ebc8c29cbf014fc450584 (patch) | |
tree | e89b2d700930d6722eb0685d8d3a9be91df851cf /packages/main/src/reactions | |
parent | test: Add tests for main window hardening (diff) | |
download | sophie-24bbe1f574ee6b0d6d0ebc8c29cbf014fc450584.tar.gz sophie-24bbe1f574ee6b0d6d0ebc8c29cbf014fc450584.tar.zst sophie-24bbe1f574ee6b0d6d0ebc8c29cbf014fc450584.zip |
feat: Save selected service to file
Sophie start off from the service that was selected when it was last
open.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/reactions')
-rw-r--r-- | packages/main/src/reactions/synchronizeConfig.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/main/src/reactions/synchronizeConfig.ts b/packages/main/src/reactions/synchronizeConfig.ts index 4a9c24b..9436c16 100644 --- a/packages/main/src/reactions/synchronizeConfig.ts +++ b/packages/main/src/reactions/synchronizeConfig.ts | |||
@@ -58,6 +58,9 @@ export default async function synchronizeConfig( | |||
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | lastConfigOnDisk = sharedStore.config; | 60 | lastConfigOnDisk = sharedStore.config; |
61 | // We can't use `comparer.structural` from `mobx`, because | ||
62 | // it handles missing values and `undefined` values differently, | ||
63 | // but JSON5 is unable to distinguish them. | ||
61 | if (!deepEqual(result.data, lastConfigOnDisk, { strict: true })) { | 64 | if (!deepEqual(result.data, lastConfigOnDisk, { strict: true })) { |
62 | await writeConfig(); | 65 | await writeConfig(); |
63 | } | 66 | } |
@@ -75,7 +78,7 @@ export default async function synchronizeConfig( | |||
75 | () => sharedStore.config, | 78 | () => sharedStore.config, |
76 | debounce((config) => { | 79 | debounce((config) => { |
77 | // We can compare snapshots by reference, since it is only recreated on store changes. | 80 | // We can compare snapshots by reference, since it is only recreated on store changes. |
78 | if (lastConfigOnDisk !== config) { | 81 | if (!deepEqual(config, lastConfigOnDisk, { strict: true })) { |
79 | writeConfig().catch((error) => { | 82 | writeConfig().catch((error) => { |
80 | log.error('Failed to write config on config change', error); | 83 | log.error('Failed to write config on config change', error); |
81 | }); | 84 | }); |