2018-07-07 00:48:14 +00:00
|
|
|
/* global window */
|
|
|
|
|
2019-05-16 22:32:38 +00:00
|
|
|
const { ipcRenderer, remote } = require('electron');
|
2018-07-03 22:33:50 +00:00
|
|
|
const url = require('url');
|
|
|
|
const i18n = require('./js/modules/i18n');
|
2019-12-17 20:25:57 +00:00
|
|
|
const { makeGetter, makeSetter } = require('./preload_utils');
|
2018-07-03 22:33:50 +00:00
|
|
|
|
2020-03-19 17:57:50 +00:00
|
|
|
const { nativeTheme } = remote.require('electron');
|
2019-05-16 22:32:38 +00:00
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
const config = url.parse(window.location.toString(), true).query;
|
|
|
|
const { locale } = config;
|
|
|
|
const localeMessages = ipcRenderer.sendSync('locale-data');
|
|
|
|
|
2019-11-07 20:07:37 +00:00
|
|
|
window.getEnvironment = () => config.environment;
|
2018-07-20 21:01:06 +00:00
|
|
|
window.getVersion = () => config.version;
|
2018-07-13 15:57:30 +00:00
|
|
|
window.theme = config.theme;
|
2018-07-03 22:33:50 +00:00
|
|
|
window.i18n = i18n.setup(locale, localeMessages);
|
2020-06-04 18:16:19 +00:00
|
|
|
window.forCalling = config.forCalling === 'true';
|
|
|
|
window.forCamera = config.forCamera === 'true';
|
2018-07-03 22:33:50 +00:00
|
|
|
|
2019-05-16 22:32:38 +00:00
|
|
|
function setSystemTheme() {
|
2020-03-19 17:57:50 +00:00
|
|
|
window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
2019-05-16 22:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setSystemTheme();
|
|
|
|
|
|
|
|
window.subscribeToSystemThemeChange = fn => {
|
2020-03-19 17:57:50 +00:00
|
|
|
nativeTheme.on('updated', () => {
|
|
|
|
setSystemTheme();
|
|
|
|
fn();
|
|
|
|
});
|
2019-05-16 22:32:38 +00:00
|
|
|
};
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
require('./js/logging');
|
|
|
|
|
|
|
|
window.closePermissionsPopup = () =>
|
|
|
|
ipcRenderer.send('close-permissions-popup');
|
|
|
|
|
|
|
|
window.setMediaPermissions = makeSetter('media-permissions');
|
2020-06-04 18:16:19 +00:00
|
|
|
window.setMediaCameraPermissions = makeSetter('media-camera-permissions');
|
2019-05-16 22:32:38 +00:00
|
|
|
window.getThemeSetting = makeGetter('theme-setting');
|
|
|
|
window.setThemeSetting = makeSetter('theme-setting');
|