Subscribe to theme change in settings

This commit is contained in:
Fedor Indutny 2021-09-29 11:37:30 -07:00 committed by GitHub
parent 64fc234490
commit bdf1287403
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 13 deletions

11
main.js
View file

@ -61,6 +61,8 @@ let mainWindow;
let mainWindowCreated = false;
let loadingWindow;
const activeWindows = new Set();
function getMainWindow() {
return mainWindow;
}
@ -312,6 +314,9 @@ function handleCommonWindowEvents(window) {
console.error(`Preload error in ${preloadPath}: `, error.message);
});
activeWindows.add(window);
window.on('closed', () => activeWindows.delete(window));
// Works only for mainWindow because it has `enablePreferredSizeMode`
let lastZoomFactor = window.webContents.getZoomFactor();
const onZoomChanged = () => {
@ -1804,8 +1809,10 @@ ipc.on('get-user-data-path', event => {
// Refresh the settings window whenever preferences change
ipc.on('preferences-changed', () => {
if (settingsWindow && settingsWindow.webContents) {
settingsWindow.webContents.send('render');
for (const window of activeWindows) {
if (window.webContents) {
window.webContents.send('preferences-changed');
}
}
});