Skip to content

Commit e5f32bf

Browse files
Merge pull request #10453 from gitbutlerapp/observe-update-preference
Fix auto-updater preference not working
2 parents 1dd58ed + 62ce4a3 commit e5f32bf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

apps/desktop/src/lib/updater/updater.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ describe('Updater', () => {
106106
}
107107
unsubscribe();
108108
});
109+
110+
test('should respect disableAutoChecks setting', async () => {
111+
const mock = vi.spyOn(backend, 'checkUpdate').mockReturnValue(mockUpdate(null));
112+
113+
// Set disableAutoChecks to true
114+
updater.disableAutoChecks.set(true);
115+
116+
// Try to check for updates (should be skipped when disabled)
117+
await updater.checkForUpdate();
118+
expect(mock).not.toHaveBeenCalled();
119+
120+
// Set disableAutoChecks to false
121+
updater.disableAutoChecks.set(false);
122+
123+
// Try to check for updates (should work when enabled)
124+
await updater.checkForUpdate();
125+
expect(mock).toHaveBeenCalledOnce();
126+
});
109127
});
110128

111129
async function mockUpdate(update: Partial<Update> | null): Promise<Update | null> {

apps/desktop/src/lib/updater/updater.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { showToast } from '$lib/notifications/toasts';
22
import { InjectionToken } from '@gitbutler/core/context';
3+
import { persisted } from '@gitbutler/shared/persisted';
34
import { get, writable } from 'svelte/store';
45
import type { PostHogWrapper } from '$lib/analytics/posthog';
56
import type {
@@ -46,7 +47,7 @@ export const UPDATE_INTERVAL_MS = 3600000; // Hourly
4647
* ./scripts/release.sh --channel nightly --version "0.5.678"
4748
*/
4849
export class UpdaterService {
49-
readonly disableAutoChecks = writable(false);
50+
readonly disableAutoChecks = persisted(false, 'disableAutoUpdateChecks');
5051
readonly loading = writable(false);
5152
readonly update = writable<UpdateStatus>({}, () => {
5253
this.start();

0 commit comments

Comments
 (0)