Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions redisinsight/desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import {
initAutoUpdaterHandlers,
launchApiServer,
initCloudHandlers,
electronStore,
} from 'desktopSrc/lib'
import { wrapErrorMessageSensitiveData } from 'desktopSrc/utils'
import { configMain as config } from 'desktopSrc/config'
import { deepLinkHandler, deepLinkWindowHandler } from 'desktopSrc/lib/app/deep-link.handlers'
import { ElectronStorageItem } from 'uiSrc/electron/constants'

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

nativeTheme.themeSource = electronStore?.get(ElectronStorageItem.themeSource) || config.themeSource

checkForUpdate(process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK)

app.setName(config.name)
Expand Down
1 change: 1 addition & 0 deletions redisinsight/desktop/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"defaultPort": 5530,
"host": "localhost",
"debug": false,
"themeSource": "dark",
"appName": "RedisInsight",
"schema": "redisinsight",
"mainWindow": {
Expand Down
7 changes: 5 additions & 2 deletions redisinsight/desktop/src/lib/app/ipc.handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { app, ipcMain, nativeTheme } from 'electron'
import { electronStore } from 'desktopSrc/lib'
import { IpcInvokeEvent } from 'uiSrc/electron/constants'
import { ElectronStorageItem, IpcInvokeEvent } from 'uiSrc/electron/constants'

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

ipcMain.handle(IpcInvokeEvent.themeChange, (_event, theme: string) => {
nativeTheme.themeSource = theme.toLowerCase()
const themeSource = theme.toLowerCase() as typeof nativeTheme.themeSource

nativeTheme.themeSource = themeSource
electronStore?.set(ElectronStorageItem.themeSource, themeSource)
})
}
4 changes: 2 additions & 2 deletions redisinsight/ui/src/contexts/themeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
const THEME_NAMES = THEMES.map(({ value }) => value)

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

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

changeTheme = (themeValue: any) => {
let actualTheme = themeValue
Expand Down
1 change: 1 addition & 0 deletions redisinsight/ui/src/electron/constants/storageElectron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum ElectronStorageItem {
isDisplayAppInTray = 'isDisplayAppInTray',
updatePreviousVersion = 'updatePreviousVersion',
zoomFactor = 'zoomFactor',
themeSource = 'themeSource',
}

export default ElectronStorageItem