diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-01-09 22:16:29 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-01-09 22:17:26 +0100 |
commit | fb7118ff1c8f0dcd61f15e51b193512283d83fa1 (patch) | |
tree | 721cee6a64b44a56b7f05f39750a65cda5fb4ef6 /packages/main/src/controllers | |
parent | build: Add eslint-plugin-jest (diff) | |
download | sophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.tar.gz sophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.tar.zst sophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.zip |
build: Add eslint-plugin-unicorn
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/controllers')
-rw-r--r-- | packages/main/src/controllers/__tests__/initConfig.spec.ts | 2 | ||||
-rw-r--r-- | packages/main/src/controllers/initConfig.ts | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/packages/main/src/controllers/__tests__/initConfig.spec.ts b/packages/main/src/controllers/__tests__/initConfig.spec.ts index 9a5f85e..11e7690 100644 --- a/packages/main/src/controllers/__tests__/initConfig.spec.ts +++ b/packages/main/src/controllers/__tests__/initConfig.spec.ts | |||
@@ -133,7 +133,7 @@ describe('when it has loaded the config', () => { | |||
133 | }); | 133 | }); |
134 | 134 | ||
135 | it('should throttle saving changes to the config file', () => { | 135 | it('should throttle saving changes to the config file', () => { |
136 | mocked(persistenceService.writeConfig).mockResolvedValue(undefined); | 136 | mocked(persistenceService.writeConfig).mockResolvedValue(); |
137 | config.setThemeSource('dark'); | 137 | config.setThemeSource('dark'); |
138 | jest.advanceTimersByTime(lessThanThrottleMs); | 138 | jest.advanceTimersByTime(lessThanThrottleMs); |
139 | config.setThemeSource('light'); | 139 | config.setThemeSource('light'); |
diff --git a/packages/main/src/controllers/initConfig.ts b/packages/main/src/controllers/initConfig.ts index e83b8da..915f451 100644 --- a/packages/main/src/controllers/initConfig.ts +++ b/packages/main/src/controllers/initConfig.ts | |||
@@ -38,7 +38,7 @@ export default async function initConfig( | |||
38 | ): Promise<Disposer> { | 38 | ): Promise<Disposer> { |
39 | log.trace('Initializing config controller'); | 39 | log.trace('Initializing config controller'); |
40 | 40 | ||
41 | let lastSnapshotOnDisk: ConfigSnapshotOut | null = null; | 41 | let lastSnapshotOnDisk: ConfigSnapshotOut | undefined; |
42 | 42 | ||
43 | async function readConfig(): Promise<boolean> { | 43 | async function readConfig(): Promise<boolean> { |
44 | const result = await persistenceService.readConfig(); | 44 | const result = await persistenceService.readConfig(); |
@@ -46,8 +46,8 @@ export default async function initConfig( | |||
46 | try { | 46 | try { |
47 | applySnapshot(config, result.data); | 47 | applySnapshot(config, result.data); |
48 | lastSnapshotOnDisk = getSnapshot(config); | 48 | lastSnapshotOnDisk = getSnapshot(config); |
49 | } catch (err) { | 49 | } catch (error) { |
50 | log.error('Failed to apply config snapshot', result.data, err); | 50 | log.error('Failed to apply config snapshot', result.data, error); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | return result.found; | 53 | return result.found; |
@@ -70,8 +70,8 @@ export default async function initConfig( | |||
70 | debounce((snapshot) => { | 70 | debounce((snapshot) => { |
71 | // We can compare snapshots by reference, since it is only recreated on store changes. | 71 | // We can compare snapshots by reference, since it is only recreated on store changes. |
72 | if (lastSnapshotOnDisk !== snapshot) { | 72 | if (lastSnapshotOnDisk !== snapshot) { |
73 | writeConfig().catch((err) => { | 73 | writeConfig().catch((error) => { |
74 | log.error('Failed to write config on config change', err); | 74 | log.error('Failed to write config on config change', error); |
75 | }); | 75 | }); |
76 | } | 76 | } |
77 | }, debounceTime), | 77 | }, debounceTime), |
@@ -80,8 +80,8 @@ export default async function initConfig( | |||
80 | const disposeWatcher = persistenceService.watchConfig(async () => { | 80 | const disposeWatcher = persistenceService.watchConfig(async () => { |
81 | try { | 81 | try { |
82 | await readConfig(); | 82 | await readConfig(); |
83 | } catch (err) { | 83 | } catch (error) { |
84 | log.error('Failed to read config', err); | 84 | log.error('Failed to read config', error); |
85 | } | 85 | } |
86 | }, debounceTime); | 86 | }, debounceTime); |
87 | 87 | ||