Skip to content

Commit bcd6c7c

Browse files
committed
Fix two menu issues
- check for updates - share debug info
1 parent 895a37d commit bcd6c7c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type DownloadEvent, Update } from '@tauri-apps/plugin-updater';
55
import { get, writable } from 'svelte/store';
66
import type { PostHogWrapper } from '$lib/analytics/posthog';
77
import type { Tauri } from '$lib/backend/tauri';
8+
import type { ShortcutService } from '$lib/shortcuts/shortcutService.svelte';
89

910
export const UPDATER_SERVICE = new InjectionToken<UpdaterService>('UpdaterService');
1011

@@ -59,11 +60,14 @@ export class UpdaterService {
5960

6061
constructor(
6162
private tauri: Tauri,
62-
private posthog: PostHogWrapper
63+
private posthog: PostHogWrapper,
64+
private shortcuts: ShortcutService
6365
) {}
6466

6567
private async start() {
66-
this.unlistenMenu = this.tauri.listen<string>('menu://global/update/clicked', () => {
68+
// This shortcut registration is never unsubscribed, but that's likely
69+
// fine for the time being since the `AppUpdater` can never unmount.
70+
this.shortcuts.on('update', () => {
6771
this.checkForUpdate(true);
6872
});
6973
this.checkForUpdateInterval = setInterval(
@@ -75,7 +79,6 @@ export class UpdaterService {
7579

7680
private async stop() {
7781
this.unlistenStatus?.();
78-
this.unlistenMenu?.();
7982
if (this.checkForUpdateInterval !== undefined) {
8083
clearInterval(this.checkForUpdateInterval);
8184
this.checkForUpdateInterval = undefined;

apps/desktop/src/routes/+layout.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
import { StackService, STACK_SERVICE } from '$lib/stacks/stackService.svelte';
7474
import { ClientState, CLIENT_STATE } from '$lib/state/clientState.svelte';
7575
import { UiState, UI_STATE } from '$lib/state/uiState.svelte';
76-
import { UPDATER_SERVICE } from '$lib/updater/updater';
76+
import { UPDATER_SERVICE, UpdaterService } from '$lib/updater/updater';
7777
import {
7878
UpstreamIntegrationService,
7979
UPSTREAM_INTEGRATION_SERVICE
@@ -199,6 +199,7 @@
199199
provide(PROJECTS_SERVICE, projectsService);
200200
201201
const shortcutService = new ShortcutService(data.tauri);
202+
const updaterService = new UpdaterService(data.tauri, data.posthog, shortcutService);
202203
const commitService = new CommitService();
203204
204205
const upstreamIntegrationService = new UpstreamIntegrationService(
@@ -249,7 +250,7 @@
249250
// Setters do not need to be reactive since `data` never updates
250251
provide(POSTHOG_WRAPPER, data.posthog);
251252
provide(USER_SERVICE, data.userService);
252-
provide(UPDATER_SERVICE, data.updaterService);
253+
provide(UPDATER_SERVICE, updaterService);
253254
provide(GIT_CONFIG_SERVICE, data.gitConfig);
254255
provide(PROMPT_SERVICE, data.promptService);
255256
provide(HTTP_CLIENT, data.httpClient);

apps/desktop/src/routes/+layout.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ProjectMetrics } from '$lib/metrics/projectMetrics';
1212
import { PromptService } from '$lib/prompt/promptService';
1313
import { RemotesService } from '$lib/remotes/remotesService';
1414
import { TokenMemoryService } from '$lib/stores/tokenMemoryService';
15-
import { UpdaterService } from '$lib/updater/updater';
1615
import { UserService } from '$lib/user/userService';
1716
import { HttpClient } from '@gitbutler/shared/network/httpClient';
1817
import { UploadsService } from '@gitbutler/shared/uploads/uploadsService';
@@ -48,8 +47,6 @@ export const load: LayoutLoad = async () => {
4847
const appSettings = await loadAppSettings();
4948
initAnalyticsIfEnabled(appSettings, posthog);
5049

51-
const updaterService = new UpdaterService(tauri, posthog);
52-
5350
const gitConfig = new GitConfigService(tauri);
5451
const remotesService = new RemotesService();
5552
const aiPromptService = new AIPromptService();
@@ -66,7 +63,6 @@ export const load: LayoutLoad = async () => {
6663
tokenMemoryService,
6764
appSettings,
6865
httpClient,
69-
updaterService,
7066
promptService,
7167
userService,
7268
gitConfig,

crates/gitbutler-tauri/src/menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub fn handle_event(webview: &WebviewWindow, event: &MenuEvent) {
304304
}
305305

306306
if event.id() == "help/share-debug-info" {
307-
emit(webview, SHORTCUT_EVENT, "share-debug");
307+
emit(webview, SHORTCUT_EVENT, "share-debug-info");
308308
return;
309309
}
310310

0 commit comments

Comments
 (0)