Merge "Respect system theme in debug log modal"

This commit is contained in:
Fedor Indutnyy 2021-09-27 13:09:22 -07:00
commit 8f9e50c3fa
2 changed files with 21 additions and 2 deletions

View file

@ -10,6 +10,7 @@ const url = require('url');
require('./ts/windows/context'); require('./ts/windows/context');
const { setupI18n } = require('./ts/util/setupI18n'); const { setupI18n } = require('./ts/util/setupI18n');
const { createSetting } = require('./ts/util/preload');
const { const {
getEnvironment, getEnvironment,
setEnvironment, setEnvironment,
@ -22,7 +23,7 @@ const localeMessages = ipcRenderer.sendSync('locale-data');
setEnvironment(parseEnvironment(config.environment)); setEnvironment(parseEnvironment(config.environment));
window.getVersion = () => config.version; window.getVersion = () => config.version;
window.theme = config.theme; window.themeSetting = createSetting('themeSetting', { setter: false });
window.i18n = setupI18n(locale, localeMessages); window.i18n = setupI18n(locale, localeMessages);
// got.js appears to need this to successfully submit debug logs to the cloud // got.js appears to need this to successfully submit debug logs to the cloud

View file

@ -10,7 +10,25 @@ $(document).on('keydown', e => {
}); });
const $body = $(document.body); const $body = $(document.body);
$body.addClass(`${window.theme}-theme`);
async function applyTheme() {
const theme = await window.themeSetting.getValue();
document.body.classList.remove('light-theme');
document.body.classList.remove('dark-theme');
document.body.classList.add(
`${
theme === 'system'
? window.SignalContext.nativeThemeListener.getSystemTheme()
: theme
}-theme`
);
}
applyTheme();
window.SignalContext.nativeThemeListener.subscribe(() => {
applyTheme();
});
// got.js appears to need this to successfully submit debug logs to the cloud // got.js appears to need this to successfully submit debug logs to the cloud
window.setImmediate = window.nodeSetImmediate; window.setImmediate = window.nodeSetImmediate;