Ensure that both window and SignalWindow are defined
This commit is contained in:
parent
e86a6119cd
commit
1b9d8dcb11
4 changed files with 5 additions and 8 deletions
|
@ -17,8 +17,7 @@ export function setupI18n(
|
|||
|
||||
const getMessage: LocalizerType = (key, substitutions) => {
|
||||
// eslint-disable-next-line no-console
|
||||
const log =
|
||||
typeof window !== 'undefined' ? window.SignalWindow.log : console;
|
||||
const log = window?.SignalWindow?.log || console;
|
||||
|
||||
const entry = messages[key];
|
||||
if (!entry) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from '../environment';
|
||||
import { strictAssert } from '../util/assert';
|
||||
import { createSetting } from '../util/preload';
|
||||
import { initialize as initializeLogging } from '../logging/set_up_renderer_logging';
|
||||
|
||||
const config = url.parse(window.location.toString(), true).query;
|
||||
const { locale } = config;
|
||||
|
@ -23,6 +24,8 @@ setEnvironment(parseEnvironment(config.environment));
|
|||
|
||||
strictAssert(Boolean(window.SignalContext), 'context must be defined');
|
||||
|
||||
initializeLogging();
|
||||
|
||||
export const SignalWindow = {
|
||||
Settings: {
|
||||
themeSetting: createSetting('themeSetting', { setter: false }),
|
||||
|
@ -34,4 +37,5 @@ export const SignalWindow = {
|
|||
getEnvironment,
|
||||
getVersion: (): string => String(config.version),
|
||||
i18n: setupI18n(locale, localeMessages),
|
||||
log: window.SignalWindow.log,
|
||||
};
|
||||
|
|
|
@ -11,7 +11,6 @@ import '../context';
|
|||
import { createSetting } from '../../util/preload';
|
||||
import { SignalWindow } from '../configure';
|
||||
import { PermissionsPopup } from '../../components/PermissionsPopup';
|
||||
import { initialize as initializeLogging } from '../../logging/set_up_renderer_logging';
|
||||
|
||||
const mediaCameraPermissions = createSetting('mediaCameraPermissions', {
|
||||
getter: false,
|
||||
|
@ -64,5 +63,3 @@ contextBridge.exposeInMainWorld('SignalWindow', {
|
|||
);
|
||||
},
|
||||
});
|
||||
|
||||
initializeLogging();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
import { initialize as initializeLogging } from '../../logging/set_up_renderer_logging';
|
||||
|
||||
// It is important to call this as early as possible
|
||||
import '../context';
|
||||
|
@ -367,5 +366,3 @@ contextBridge.exposeInMainWorld('SignalWindow', {
|
|||
...SignalWindow,
|
||||
renderWindow: renderPreferences,
|
||||
});
|
||||
|
||||
initializeLogging();
|
||||
|
|
Loading…
Reference in a new issue