Get native theme through IPC not remote

This commit is contained in:
Fedor Indutny
2021-06-30 11:57:43 -07:00
committed by GitHub
parent d2cc8e5aa9
commit 71572db7a9
16 changed files with 227 additions and 60 deletions

View File

@@ -3,7 +3,7 @@
/* global window */
const { ipcRenderer, remote } = require('electron');
const { ipcRenderer } = require('electron');
const url = require('url');
const i18n = require('./js/modules/i18n');
@@ -18,11 +18,9 @@ const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
setEnvironment(parseEnvironment(config.environment));
const { nativeTheme } = remote.require('electron');
const { Context: SignalContext } = require('./ts/context');
window.SignalContext = new SignalContext();
window.SignalContext = new SignalContext(ipcRenderer);
window.platform = process.platform;
window.theme = config.theme;
@@ -30,19 +28,6 @@ window.i18n = i18n.setup(locale, localeMessages);
window.appStartInitialSpellcheckSetting =
config.appStartInitialSpellcheckSetting === 'true';
function setSystemTheme() {
window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
}
setSystemTheme();
window.subscribeToSystemThemeChange = fn => {
nativeTheme.on('updated', () => {
setSystemTheme();
fn();
});
};
window.getEnvironment = getEnvironment;
window.getVersion = () => config.version;
window.getAppInstance = () => config.appInstance;