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

@@ -19,7 +19,6 @@ const {
const { makeGetter } = require('../preload_utils');
const { dialog } = remote;
const { nativeTheme } = remote.require('electron');
const { Context: SignalContext } = require('../ts/context');
@@ -29,7 +28,7 @@ const MAX_STICKER_DIMENSION = STICKER_SIZE;
const MAX_WEBP_STICKER_BYTE_LENGTH = 100 * 1024;
const MAX_ANIMATED_STICKER_BYTE_LENGTH = 300 * 1024;
window.SignalContext = new SignalContext();
window.SignalContext = new SignalContext(ipc);
setEnvironment(parseEnvironment(config.environment));
@@ -280,6 +279,7 @@ const getThemeSetting = makeGetter('theme-setting');
async function resolveTheme() {
const theme = (await getThemeSetting()) || 'system';
if (process.platform === 'darwin' && theme === 'system') {
const { theme: nativeTheme } = window.SignalContext.nativeThemeListener;
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
}
return theme;
@@ -293,8 +293,6 @@ async function applyTheme() {
window.addEventListener('DOMContentLoaded', applyTheme);
nativeTheme.on('updated', () => {
applyTheme();
});
window.SignalContext.nativeThemeListener.subscribe(() => applyTheme());
window.log.info('sticker-creator preload complete...');