2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-10-06 16:16:51 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { contextBridge, ipcRenderer } from 'electron';
|
2023-04-20 21:23:19 +00:00
|
|
|
import { MinimalSignalContext } from '../minimalContext';
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2023-04-20 21:23:19 +00:00
|
|
|
function downloadLog(logText: string) {
|
|
|
|
ipcRenderer.send('show-debug-log-save-dialog', logText);
|
|
|
|
}
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2023-04-20 21:23:19 +00:00
|
|
|
async function fetchLogs() {
|
|
|
|
const data = await ipcRenderer.invoke('fetch-log');
|
|
|
|
return ipcRenderer.invoke(
|
|
|
|
'DebugLogs.getLogs',
|
|
|
|
data,
|
|
|
|
window.navigator.userAgent
|
|
|
|
);
|
|
|
|
}
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2023-04-20 21:23:19 +00:00
|
|
|
function uploadLogs(logs: string) {
|
|
|
|
return ipcRenderer.invoke('DebugLogs.upload', logs);
|
|
|
|
}
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2023-04-20 21:23:19 +00:00
|
|
|
const Signal = {
|
|
|
|
DebugLogWindowProps: {
|
|
|
|
downloadLog,
|
|
|
|
fetchLogs,
|
|
|
|
uploadLogs,
|
2021-10-06 16:16:51 +00:00
|
|
|
},
|
2023-04-20 21:23:19 +00:00
|
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld('Signal', Signal);
|
|
|
|
contextBridge.exposeInMainWorld('SignalContext', MinimalSignalContext);
|