From f5f27eddc93314e8e10ab96c7bdb5c626142a1d3 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Mon, 27 Dec 2021 19:41:46 +0100 Subject: refactor: Inversion of control with typed-inject --- packages/main/src/services/NativeThemeService.ts | 38 ------------------------ 1 file changed, 38 deletions(-) delete mode 100644 packages/main/src/services/NativeThemeService.ts (limited to 'packages/main/src/services/NativeThemeService.ts') diff --git a/packages/main/src/services/NativeThemeService.ts b/packages/main/src/services/NativeThemeService.ts deleted file mode 100644 index 7a26c3c..0000000 --- a/packages/main/src/services/NativeThemeService.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2021-2022 Kristóf Marussy - * - * This file is part of Sophie. - * - * Sophie is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import { nativeTheme } from 'electron'; -import type { IDisposer } from 'mobx-state-tree'; -import type { ThemeSource } from '@sophie/shared'; - -export class NativeThemeService { - setThemeSource(themeSource: ThemeSource): void { - nativeTheme.themeSource = themeSource; - } - - onShouldUseDarkColorsUpdated(callback: (shouldUseDarkColors: boolean) => void): IDisposer { - const wrappedCallback = () => { - callback(nativeTheme.shouldUseDarkColors); - }; - wrappedCallback(); - nativeTheme.on('updated', wrappedCallback); - return () => nativeTheme.off('updated', wrappedCallback); - } -} -- cgit v1.2.3-54-g00ecf