Skip to content

Commit f473d79

Browse files
Merge pull request #2641 from RedisInsight/fe/bugfix/RI-4981
Fe/bugfix/ri 4981
2 parents df288a7 + 076c2bb commit f473d79

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

redisinsight/desktop/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import {
1313
initAutoUpdaterHandlers,
1414
launchApiServer,
1515
initCloudHandlers,
16+
electronStore,
1617
} from 'desktopSrc/lib'
1718
import { wrapErrorMessageSensitiveData } from 'desktopSrc/utils'
1819
import { configMain as config } from 'desktopSrc/config'
1920
import { deepLinkHandler, deepLinkWindowHandler } from 'desktopSrc/lib/app/deep-link.handlers'
21+
import { ElectronStorageItem } from 'uiSrc/electron/constants'
2022

2123
if (!config.isProduction) {
2224
const sourceMapSupport = require('source-map-support')
@@ -33,6 +35,8 @@ const init = async () => {
3335
initTray()
3436
initCloudHandlers()
3537

38+
nativeTheme.themeSource = electronStore?.get(ElectronStorageItem.themeSource) || config.themeSource
39+
3640
checkForUpdate(process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK)
3741

3842
app.setName(config.name)

redisinsight/desktop/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"defaultPort": 5530,
44
"host": "localhost",
55
"debug": false,
6+
"themeSource": "dark",
67
"appName": "RedisInsight",
78
"schema": "redisinsight",
89
"mainWindow": {
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { app, ipcMain, nativeTheme } from 'electron'
22
import { electronStore } from 'desktopSrc/lib'
3-
import { IpcInvokeEvent } from 'uiSrc/electron/constants'
3+
import { ElectronStorageItem, IpcInvokeEvent } from 'uiSrc/electron/constants'
44

55
export const initIPCHandlers = () => {
66
ipcMain.handle(IpcInvokeEvent.getAppVersion, () => app?.getVersion())
@@ -10,6 +10,9 @@ export const initIPCHandlers = () => {
1010
ipcMain.handle(IpcInvokeEvent.deleteStoreValue, (_event, key) => electronStore?.delete(key))
1111

1212
ipcMain.handle(IpcInvokeEvent.themeChange, (_event, theme: string) => {
13-
nativeTheme.themeSource = theme.toLowerCase()
13+
const themeSource = theme.toLowerCase() as typeof nativeTheme.themeSource
14+
15+
nativeTheme.themeSource = themeSource
16+
electronStore?.set(ElectronStorageItem.themeSource, themeSource)
1417
})
1518
}

redisinsight/ui/src/contexts/themeContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Props {
99
const THEME_NAMES = THEMES.map(({ value }) => value)
1010

1111
export const defaultState = {
12-
theme: THEME_NAMES[0],
12+
theme: THEME_NAMES[1], // dark theme by default
1313
usingSystemTheme: localStorageService.get(BrowserStorageItem.theme) === Theme.System,
1414
changeTheme: (themeValue: any) => {
1515
themeService.applyTheme(themeValue)
@@ -36,7 +36,7 @@ export class ThemeProvider extends React.Component<Props> {
3636
}
3737
}
3838

39-
getSystemTheme = () => window.matchMedia && window.matchMedia(THEME_MATCH_MEDIA_DARK).matches ? Theme.Dark : Theme.Light
39+
getSystemTheme = () => (window.matchMedia && window.matchMedia(THEME_MATCH_MEDIA_DARK).matches ? Theme.Dark : Theme.Light)
4040

4141
changeTheme = (themeValue: any) => {
4242
let actualTheme = themeValue

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum ElectronStorageItem {
66
isDisplayAppInTray = 'isDisplayAppInTray',
77
updatePreviousVersion = 'updatePreviousVersion',
88
zoomFactor = 'zoomFactor',
9+
themeSource = 'themeSource',
910
}
1011

1112
export default ElectronStorageItem

0 commit comments

Comments
 (0)