Skip to content

Commit 1a89a50

Browse files
committed
Invoke ipc event to change window theme
1 parent db5a79d commit 1a89a50

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

redisinsight/desktop/src/lib/app/ipc.handlers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, ipcMain } from 'electron'
1+
import { app, ipcMain, nativeTheme } from 'electron'
22
import { electronStore } from 'desktopSrc/lib'
33
import { IpcInvokeEvent } from 'uiSrc/electron/constants'
44

@@ -8,4 +8,8 @@ export const initIPCHandlers = () => {
88
ipcMain.handle(IpcInvokeEvent.getStoreValue, (_event, key) => electronStore?.get(key))
99

1010
ipcMain.handle(IpcInvokeEvent.deleteStoreValue, (_event, key) => electronStore?.delete(key))
11+
12+
ipcMain.handle(IpcInvokeEvent.themeChange, (_event, theme: string) => {
13+
nativeTheme.themeSource = theme.toLowerCase()
14+
})
1115
}

redisinsight/ui/src/contexts/themeContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class ThemeProvider extends React.Component<Props> {
4343
if (themeValue === Theme.System) {
4444
actualTheme = this.getSystemTheme()
4545
}
46+
window.app?.ipc?.invoke?.('theme:change', themeValue)
4647

4748
this.setState({ theme: actualTheme, usingSystemTheme: themeValue === Theme.System }, () => {
4849
themeService.applyTheme(themeValue)

redisinsight/ui/src/electron/constants/ipcEvent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ enum IpcInvokeEvent {
44
getAppVersion = 'app:get:version',
55
cloudOauth = 'cloud:oauth',
66
windowOpen = 'window:open',
7+
themeChange = 'theme:change',
78
}
89

910
enum IpcOnEvent {

0 commit comments

Comments
 (0)