2021-10-06 16:16:51 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import { contextBridge, ipcRenderer } from 'electron';
|
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
import { SignalContext } from '../context';
|
2021-10-06 16:16:51 +00:00
|
|
|
import { DebugLogWindow } from '../../components/DebugLogWindow';
|
|
|
|
import * as debugLog from '../../logging/debuglogs';
|
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
contextBridge.exposeInMainWorld('SignalContext', {
|
|
|
|
...SignalContext,
|
2021-10-06 16:16:51 +00:00
|
|
|
renderWindow: () => {
|
2021-10-07 23:28:47 +00:00
|
|
|
const environmentText: Array<string> = [SignalContext.getEnvironment()];
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
const appInstance = SignalContext.getAppInstance();
|
2021-10-06 16:16:51 +00:00
|
|
|
if (appInstance) {
|
|
|
|
environmentText.push(appInstance);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
React.createElement(DebugLogWindow, {
|
|
|
|
closeWindow: () => ipcRenderer.send('close-debug-log'),
|
|
|
|
downloadLog: (logText: string) =>
|
|
|
|
ipcRenderer.send('show-debug-log-save-dialog', logText),
|
2021-10-07 23:28:47 +00:00
|
|
|
i18n: SignalContext.i18n,
|
2021-10-06 16:16:51 +00:00
|
|
|
fetchLogs() {
|
|
|
|
return debugLog.fetch(
|
2021-10-07 23:28:47 +00:00
|
|
|
SignalContext.getNodeVersion(),
|
|
|
|
SignalContext.getVersion()
|
2021-10-06 16:16:51 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
uploadLogs(logs: string) {
|
2021-10-07 23:28:47 +00:00
|
|
|
return debugLog.upload(logs, SignalContext.getVersion());
|
2021-10-06 16:16:51 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
document.getElementById('app')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|