Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix System Default theme not listening to system theme change #1093

Merged
merged 1 commit into from
Dec 26, 2024
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
12 changes: 11 additions & 1 deletion js/main-window.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } from 'electron';
import { app, BrowserWindow, dialog, ipcMain, Menu, nativeTheme, shell, Tray } from 'electron';
import path from 'path';
import Store from 'electron-store';

Expand Down Expand Up @@ -162,6 +162,16 @@ function createWindow()
}
});

// Listen for system theme changes in real-time
nativeTheme.on('updated', () =>
{
const savedPreferences = getUserPreferences();
const theme = savedPreferences['theme'];
if (theme === 'system-default')
{
mainWindow.webContents.send('RELOAD_THEME', theme);
}
});
}

function triggerStartupDialogs()
Expand Down
1 change: 1 addition & 0 deletions renderer/preload-scripts/calendar-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const calendarApi = {
handleWaiverSaved: (callback) => ipcRenderer.on('WAIVER_SAVED', callback),
handleCalendarReload: (callback) => ipcRenderer.on('RELOAD_CALENDAR', callback),
handlePunchDate: (callback) => ipcRenderer.on('PUNCH_DATE', callback),
handleThemeChange: (callback) => ipcRenderer.on('RELOAD_THEME', callback),
handleLeaveBy: (callback) => ipcRenderer.on('GET_LEAVE_BY', callback),
resizeMainWindow: () => resizeMainWindow(),
switchView: () => switchView(),
Expand Down
8 changes: 8 additions & 0 deletions src/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ window.mainApi.handlePunchDate(() =>
calendar.punchDate();
});

/*
* Reload theme.
*/
window.mainApi.handleThemeChange(async(event, theme) =>
{
applyTheme(theme);
});

/*
* Returns value of "leave by" for notifications.
*/
Expand Down