From 24bbe1f574ee6b0d6d0ebc8c29cbf014fc450584 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 28 Jan 2022 01:07:56 +0100 Subject: feat: Save selected service to file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sophie start off from the service that was selected when it was last open. Signed-off-by: Kristóf Marussy --- packages/main/src/reactions/synchronizeConfig.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'packages/main/src/reactions/synchronizeConfig.ts') 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( return true; } lastConfigOnDisk = sharedStore.config; + // We can't use `comparer.structural` from `mobx`, because + // it handles missing values and `undefined` values differently, + // but JSON5 is unable to distinguish them. if (!deepEqual(result.data, lastConfigOnDisk, { strict: true })) { await writeConfig(); } @@ -75,7 +78,7 @@ export default async function synchronizeConfig( () => sharedStore.config, debounce((config) => { // We can compare snapshots by reference, since it is only recreated on store changes. - if (lastConfigOnDisk !== config) { + if (!deepEqual(config, lastConfigOnDisk, { strict: true })) { writeConfig().catch((error) => { log.error('Failed to write config on config change', error); }); -- cgit v1.2.3-70-g09d2