Skip to content

Commit

Permalink
app: Set background based on theme
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Dec 31, 2020
1 parent 760f63c commit 356efa7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/main.ts
Expand Up @@ -16,6 +16,7 @@ import {userInfo} from 'src/shared/sentry/main';
import store from 'src/shared/store';
import {loadMainConfig, observeStore, registerMainIpc} from 'src/shared/store/ipc';
import connectNetworkStore from 'src/shared/store/network';
import theme from 'src/theme';

// Update the store with user details ASAP
(async () => set(store, {user: await userInfo}))();
Expand All @@ -36,6 +37,9 @@ const createWindow = () => {
titleBarStyle: 'hiddenInset',
title: 'Prolink Tools',
webPreferences: {nodeIntegration: true, contextIsolation: false},
backgroundColor: nativeTheme.shouldUseDarkColors
? theme.dark.background
: theme.light.background,
});

win.on('closed', () => (win = null));
Expand Down Expand Up @@ -66,9 +70,9 @@ const createWindow = () => {
};

app.on('ready', async () => {
await loadMainConfig();
createWindow();

await loadMainConfig();
registerMainIpc();
runConfigMigrations();
observeStore();
Expand Down Expand Up @@ -124,6 +128,13 @@ app.on('activate', () => {

reaction(
() => store.config.theme,
theme => (nativeTheme.themeSource = theme),
schema => {
const bg = nativeTheme.shouldUseDarkColors
? theme.dark.background
: theme.light.background;

nativeTheme.themeSource = schema;
win?.setBackgroundColor(bg);
},
{fireImmediately: true}
);

1 comment on commit 356efa7

@vercel
Copy link

@vercel vercel bot commented on 356efa7 Dec 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.