diff --git a/core/src/api/index.ts b/core/src/api/index.ts index b45a41d0e3..c5d5b4fe77 100644 --- a/core/src/api/index.ts +++ b/core/src/api/index.ts @@ -3,9 +3,6 @@ * @description Enum of all the routes exposed by the app */ export enum AppRoute { - setNativeThemeLight = 'setNativeThemeLight', - setNativeThemeDark = 'setNativeThemeDark', - setNativeThemeSystem = 'setNativeThemeSystem', appDataPath = 'appDataPath', appVersion = 'appVersion', getResourcePath = 'getResourcePath', diff --git a/electron/handlers/app.ts b/electron/handlers/app.ts index f688d3d47b..fc2d0ee596 100644 --- a/electron/handlers/app.ts +++ b/electron/handlers/app.ts @@ -8,30 +8,6 @@ import { AppRoute } from '@janhq/core' import { getResourcePath } from './../utils/path' export function handleAppIPCs() { - /** - * Handles the "setNativeThemeLight" IPC message by setting the native theme source to "light". - * This will change the appearance of the app to the light theme. - */ - ipcMain.handle(AppRoute.setNativeThemeLight, () => { - nativeTheme.themeSource = 'light' - }) - - /** - * Handles the "setNativeThemeDark" IPC message by setting the native theme source to "dark". - * This will change the appearance of the app to the dark theme. - */ - ipcMain.handle(AppRoute.setNativeThemeDark, () => { - nativeTheme.themeSource = 'dark' - }) - - /** - * Handles the "setNativeThemeSystem" IPC message by setting the native theme source to "system". - * This will change the appearance of the app to match the system's current theme. - */ - ipcMain.handle(AppRoute.setNativeThemeSystem, () => { - nativeTheme.themeSource = 'system' - }) - /** * Returns the version of the app. * @param _event - The IPC event object. diff --git a/web/containers/Layout/index.tsx b/web/containers/Layout/index.tsx index 12f1192505..c806fddddb 100644 --- a/web/containers/Layout/index.tsx +++ b/web/containers/Layout/index.tsx @@ -15,22 +15,11 @@ const BaseLayout = (props: PropsWithChildren) => { const { children } = props const { mainViewState } = useMainViewState() - const { theme } = useTheme() + const { theme, setTheme } = useTheme() - // Force set theme native useEffect(() => { - async function setTheme() { - switch (theme) { - case 'light': - return await window?.electronAPI.setNativeThemeLight() - case 'dark': - return await window?.electronAPI.setNativeThemeDark() - default: - return await window?.electronAPI.setNativeThemeSystem() - } - } - setTheme() - }, [theme]) + setTheme(theme as string) + }, [setTheme, theme]) return (