From fa70df366cc34481e3aec47caca3f3546d1f31da Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 27 Jan 2023 20:04:29 +0500 Subject: [PATCH] desktop: migrate theme config to typescript --- apps/web/desktop/config/{theme.js => theme.ts} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename apps/web/desktop/config/{theme.js => theme.ts} (87%) diff --git a/apps/web/desktop/config/theme.js b/apps/web/desktop/config/theme.ts similarity index 87% rename from apps/web/desktop/config/theme.js rename to apps/web/desktop/config/theme.ts index 3e6cf612a..832ec05d8 100644 --- a/apps/web/desktop/config/theme.js +++ b/apps/web/desktop/config/theme.ts @@ -20,14 +20,15 @@ along with this program. If not, see . import { JSONStorage } from "../jsonstorage"; import { nativeTheme } from "electron"; -function getTheme() { - return JSONStorage.get("theme") || nativeTheme.themeSource; +type Theme = typeof nativeTheme.themeSource; +function getTheme(): Theme { + return JSONStorage.get("theme", nativeTheme.themeSource); } -function setTheme(theme) { +function setTheme(theme: Theme) { changeTheme(theme); if (globalThis.window) - globalThis.window.setBackgroundColor(getBackgroundColor(theme)); + globalThis.window.setBackgroundColor(getBackgroundColor()); return JSONStorage.set("theme", theme); } @@ -53,7 +54,7 @@ function getSystemTheme() { export { getTheme, setTheme, getBackgroundColor, getSystemTheme }; -function changeTheme(theme) { +function changeTheme(theme: Theme) { const listeners = nativeTheme.rawListeners("updated"); nativeTheme.removeAllListeners("updated");