diff options
Diffstat (limited to 'packages/main/src/controllers/initConfig.ts')
-rw-r--r-- | packages/main/src/controllers/initConfig.ts | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/packages/main/src/controllers/initConfig.ts b/packages/main/src/controllers/initConfig.ts index 1d40762..e83b8da 100644 --- a/packages/main/src/controllers/initConfig.ts +++ b/packages/main/src/controllers/initConfig.ts | |||
@@ -59,20 +59,23 @@ export default async function initConfig( | |||
59 | lastSnapshotOnDisk = snapshot; | 59 | lastSnapshotOnDisk = snapshot; |
60 | } | 60 | } |
61 | 61 | ||
62 | if (!await readConfig()) { | 62 | if (!(await readConfig())) { |
63 | log.info('Config file was not found'); | 63 | log.info('Config file was not found'); |
64 | await writeConfig(); | 64 | await writeConfig(); |
65 | log.info('Created config file'); | 65 | log.info('Created config file'); |
66 | } | 66 | } |
67 | 67 | ||
68 | const disposeOnSnapshot = onSnapshot(config, debounce((snapshot) => { | 68 | const disposeOnSnapshot = onSnapshot( |
69 | // We can compare snapshots by reference, since it is only recreated on store changes. | 69 | config, |
70 | if (lastSnapshotOnDisk !== snapshot) { | 70 | debounce((snapshot) => { |
71 | writeConfig().catch((err) => { | 71 | // We can compare snapshots by reference, since it is only recreated on store changes. |
72 | log.error('Failed to write config on config change', err); | 72 | if (lastSnapshotOnDisk !== snapshot) { |
73 | }); | 73 | writeConfig().catch((err) => { |
74 | } | 74 | log.error('Failed to write config on config change', err); |
75 | }, debounceTime)); | 75 | }); |
76 | } | ||
77 | }, debounceTime), | ||
78 | ); | ||
76 | 79 | ||
77 | const disposeWatcher = persistenceService.watchConfig(async () => { | 80 | const disposeWatcher = persistenceService.watchConfig(async () => { |
78 | try { | 81 | try { |