Skip to content

Commit

Permalink
fix: dark mode not toggling with system (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored Sep 18, 2021
1 parent 8b186a9 commit 75eb1c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ipcMain, app } = require('electron');
const { ipcMain, app, nativeTheme } = require('electron');
const { menubar } = require('menubar');
const { autoUpdater } = require('electron-updater');
const { onFirstRunMaybe } = require('./first-run');
Expand Down Expand Up @@ -54,6 +54,14 @@ menubarApp.on('ready', () => {

autoUpdater.checkForUpdatesAndNotify();

nativeTheme.on('updated', () => {
if (nativeTheme.shouldUseDarkColors) {
menubarApp.window.webContents.send('update-native-theme', 'DARK');
} else {
menubarApp.window.webContents.send('update-native-theme', 'LIGHT');
}
});

ipcMain.on('reopen-window', () => menubarApp.showWindow());
ipcMain.on('app-quit', () => menubarApp.app.quit());
ipcMain.on('update-icon', (_, arg) => {
Expand Down
7 changes: 7 additions & 0 deletions src/routes/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ import { IconAddAccount } from '../icons/AddAccount';
import { IconLogOut } from '../icons/Logout';
import { IconQuit } from '../icons/Quit';
import { updateTrayIcon } from '../utils/comms';
import { setAppearance } from '../utils/appearance';

const isLinux = remote.process.platform === 'linux';

export const SettingsRoute: React.FC = () => {
const { settings, updateSetting, logout } = useContext(AppContext);
const history = useHistory();

ipcRenderer.on('update-native-theme', (_, updatedAppearance: Appearance) => {
if (settings.appearance === Appearance.SYSTEM) {
setAppearance(updatedAppearance);
}
});

const logoutUser = useCallback(() => {
logout();
history.goBack();
Expand Down

0 comments on commit 75eb1c8

Please sign in to comment.