summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts55
-rw-r--r--gui/src/shared/ipc-event-channel.ts66
2 files changed, 65 insertions, 56 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 87d0de1d2e..27bfc61640 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -977,41 +977,44 @@ class ApplicationMain {
}
});
- ipcMain.on('collect-logs', (event: Electron.Event, requestId: string, toRedact: string[]) => {
- const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log');
- const executable = resolveBin('problem-report');
- const args = ['collect', '--output', reportPath];
- if (toRedact.length > 0) {
- args.push('--redact', ...toRedact);
- }
+ ipcMain.on(
+ 'collect-logs',
+ (event: Electron.IpcMainEvent, requestId: string, toRedact: string[]) => {
+ const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log');
+ const executable = resolveBin('problem-report');
+ const args = ['collect', '--output', reportPath];
+ if (toRedact.length > 0) {
+ args.push('--redact', ...toRedact);
+ }
- execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
- if (error) {
- log.error(
- `Failed to collect a problem report.
+ execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
+ if (error) {
+ log.error(
+ `Failed to collect a problem report.
Stdout: ${stdout.toString()}
Stderr: ${stderr.toString()}`,
- );
+ );
- event.sender.send('collect-logs-reply', requestId, {
- success: false,
- error: error.message,
- });
- } else {
- log.debug(`Problem report was written to ${reportPath}`);
+ event.sender.send('collect-logs-reply', requestId, {
+ success: false,
+ error: error.message,
+ });
+ } else {
+ log.debug(`Problem report was written to ${reportPath}`);
- event.sender.send('collect-logs-reply', requestId, {
- success: true,
- reportPath,
- });
- }
- });
- });
+ event.sender.send('collect-logs-reply', requestId, {
+ success: true,
+ reportPath,
+ });
+ }
+ });
+ },
+ );
ipcMain.on(
'send-problem-report',
(
- event: Electron.Event,
+ event: Electron.IpcMainEvent,
requestId: string,
email: string,
message: string,
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index f57368db2d..8283cf43dc 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -265,7 +265,7 @@ export class IpcRendererEventChannel {
export class IpcMainEventChannel {
public static state = {
handleGet(fn: () => IAppStateSnapshot) {
- ipcMain.on(GET_APP_STATE, (event: Electron.Event) => {
+ ipcMain.on(GET_APP_STATE, (event: Electron.IpcMainEvent) => {
event.returnValue = fn();
});
},
@@ -349,7 +349,7 @@ export class IpcMainEventChannel {
function listen<T>(event: string): (fn: (value: T) => void) => void {
return (fn: (value: T) => void) => {
- ipcRenderer.on(event, (_event: Electron.Event, newState: T) => fn(newState));
+ ipcRenderer.on(event, (_event: Electron.IpcRendererEvent, newState: T) => fn(newState));
};
}
@@ -381,7 +381,7 @@ function senderVoid(event: string): (webContents: WebContents) => void {
function handler<T>(event: string): (handlerFn: (value: T) => void) => void {
return (handlerFn: (value: T) => void) => {
- ipcMain.on(event, (_event: Electron.Event, newValue: T) => {
+ ipcMain.on(event, (_event: Electron.IpcMainEvent, newValue: T) => {
handlerFn(newValue);
});
};
@@ -391,26 +391,29 @@ type RequestResult<T> = { type: 'success'; value: T } | { type: 'error'; message
function requestHandler<T>(event: string): (fn: (...args: any[]) => Promise<T>) => void {
return (fn: (...args: any[]) => Promise<T>) => {
- ipcMain.on(event, async (ipcEvent: Electron.Event, requestId: string, ...args: any[]) => {
- const responseEvent = `${event}-${requestId}`;
- try {
- const result: RequestResult<T> = { type: 'success', value: await fn(...args) };
+ ipcMain.on(
+ event,
+ async (ipcEvent: Electron.IpcMainEvent, requestId: string, ...args: any[]) => {
+ const responseEvent = `${event}-${requestId}`;
+ try {
+ const result: RequestResult<T> = { type: 'success', value: await fn(...args) };
- if (ipcEvent.sender.isDestroyed()) {
- log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`);
- } else {
- ipcEvent.sender.send(responseEvent, result);
- }
- } catch (error) {
- const result: RequestResult<T> = { type: 'error', message: error.message || '' };
+ if (ipcEvent.sender.isDestroyed()) {
+ log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`);
+ } else {
+ ipcEvent.sender.send(responseEvent, result);
+ }
+ } catch (error) {
+ const result: RequestResult<T> = { type: 'error', message: error.message || '' };
- if (ipcEvent.sender.isDestroyed()) {
- log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`);
- } else {
- ipcEvent.sender.send(responseEvent, result);
+ if (ipcEvent.sender.isDestroyed()) {
+ log.debug(`Cannot send the reply for ${responseEvent} since the sender was destroyed.`);
+ } else {
+ ipcEvent.sender.send(responseEvent, result);
+ }
}
- }
- });
+ },
+ );
};
}
@@ -420,17 +423,20 @@ function requestSender<T>(event: string): (...args: any[]) => Promise<T> {
const requestId = uuid.v4();
const responseEvent = `${event}-${requestId}`;
- ipcRenderer.once(responseEvent, (_ipcEvent: Electron.Event, result: RequestResult<T>) => {
- switch (result.type) {
- case 'error':
- reject(new Error(result.message));
- break;
+ ipcRenderer.once(
+ responseEvent,
+ (_ipcEvent: Electron.IpcRendererEvent, result: RequestResult<T>) => {
+ switch (result.type) {
+ case 'error':
+ reject(new Error(result.message));
+ break;
- case 'success':
- resolve(result.value);
- break;
- }
- });
+ case 'success':
+ resolve(result.value);
+ break;
+ }
+ },
+ );
ipcRenderer.send(event, requestId, ...args);
});