From 4b91b1e4fc6484fe4f83567e6d8e3ce653c5815b Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Thu, 7 May 2026 02:40:26 +0200 Subject: [PATCH] chore(events): remove dead UPDATE_THEME event and onSystemThemeUpdate API --- src/preload/index.test.ts | 19 ------------------- src/preload/index.ts | 9 --------- src/renderer/__helpers__/vitest.setup.ts | 1 - src/shared/events.ts | 2 -- 4 files changed, 31 deletions(-) diff --git a/src/preload/index.test.ts b/src/preload/index.test.ts index 55d508f3f..f580bd2ab 100644 --- a/src/preload/index.test.ts +++ b/src/preload/index.test.ts @@ -66,7 +66,6 @@ interface TestApi { tray: { updateColor: (n?: number) => void }; openExternalLink: (u: string, f: boolean) => void; app: { version: () => Promise; show?: () => void; hide?: () => void }; - onSystemThemeUpdate: (cb: (t: string) => void) => void; raiseNativeNotification: (t: string, b: string, u?: string) => unknown; } @@ -134,24 +133,6 @@ describe('preload/index', () => { process.env.NODE_ENV = originalEnv; }); - it('onSystemThemeUpdate registers listener', async () => { - const api = getExposedApi(); - const callback = vi.fn(); - api.onSystemThemeUpdate(callback); - - expect(onRendererEventMock).toHaveBeenCalledWith( - EVENTS.UPDATE_THEME, - expect.any(Function), - ); - - // Simulate event - const listener = onRendererEventMock.mock.calls[0][1]; - - listener({}, 'dark'); - - expect(callback).toHaveBeenCalledWith('dark'); - }); - it('raiseNativeNotification without url calls app.show', async () => { const api = getExposedApi(); diff --git a/src/preload/index.ts b/src/preload/index.ts index f4c79e0e0..a3730d14c 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -192,15 +192,6 @@ export const api = { onRendererEvent(EVENTS.AUTH_CALLBACK, (_, url) => callback(url)); }, - /** - * Register a callback invoked when the OS system theme changes. - * - * @param callback - Called with the new theme string (`"light"` or `"dark"`). - */ - onSystemThemeUpdate: (callback: (theme: string) => void) => { - onRendererEvent(EVENTS.UPDATE_THEME, (_, theme) => callback(theme)); - }, - /** * Display a native OS notification. * diff --git a/src/renderer/__helpers__/vitest.setup.ts b/src/renderer/__helpers__/vitest.setup.ts index 2c5914c89..111d85220 100644 --- a/src/renderer/__helpers__/vitest.setup.ts +++ b/src/renderer/__helpers__/vitest.setup.ts @@ -59,7 +59,6 @@ window.gitify = { notificationSoundPath: vi.fn(), onAuthCallback: vi.fn(), onResetApp: vi.fn(), - onSystemThemeUpdate: vi.fn(), setAutoLaunch: vi.fn(), applyKeyboardShortcut: vi.fn().mockResolvedValue({ success: true }), raiseNativeNotification: vi.fn(), diff --git a/src/shared/events.ts b/src/shared/events.ts index 07832bf2e..b67127c17 100644 --- a/src/shared/events.ts +++ b/src/shared/events.ts @@ -21,7 +21,6 @@ export const EVENTS = { NOTIFICATION_SOUND_PATH: `${P}notification-sound-path`, OPEN_EXTERNAL: `${P}open-external`, RESET_APP: `${P}reset-app`, - UPDATE_THEME: `${P}update-theme`, TWEMOJI_DIRECTORY: `${P}twemoji-directory`, } as const; @@ -87,7 +86,6 @@ export type EventContracts = AssertEventCoverage<{ [EVENTS.NOTIFICATION_SOUND_PATH]: { request: undefined; response: string }; [EVENTS.OPEN_EXTERNAL]: { request: IOpenExternal; response: undefined }; [EVENTS.RESET_APP]: { request: undefined; response: undefined }; - [EVENTS.UPDATE_THEME]: { request: string; response: undefined }; [EVENTS.TWEMOJI_DIRECTORY]: { request: undefined; response: string }; }>;