summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-12-10 13:28:22 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-12-10 13:28:22 +0100
commita832f6f3628272166d7232e839b4fc5091ecdafd (patch)
tree408d279f13563c86ef3b1bee505329eddb829ee5 /gui/src/main
parentae3cae40c16b01683b2a562ac48799699c711ca2 (diff)
parent8f4698a13622d6e34e47c5c2a2d043ffd1276e95 (diff)
downloadmullvadvpn-a832f6f3628272166d7232e839b4fc5091ecdafd.tar.xz
mullvadvpn-a832f6f3628272166d7232e839b4fc5091ecdafd.zip
Merge branch 'remove-use-of-legacy-ipc-calls'
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/index.ts89
1 files changed, 27 insertions, 62 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 36744104b5..159c8b7dfa 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -1,15 +1,5 @@
import { execFile } from 'child_process';
-import {
- app,
- BrowserWindow,
- ipcMain,
- Menu,
- nativeImage,
- screen,
- session,
- shell,
- Tray,
-} from 'electron';
+import { app, BrowserWindow, Menu, nativeImage, screen, session, shell, Tray } from 'electron';
import log from 'electron-log';
import mkdirp from 'mkdirp';
import moment from 'moment';
@@ -530,6 +520,11 @@ class ApplicationMain {
if (this.windowController) {
IpcMainEventChannel.daemonConnected.notify(this.windowController.webContents);
}
+
+ // show window when account is not set
+ if (!this.settings.accountToken) {
+ this.windowController?.show();
+ }
};
private onDaemonDisconnected = (error?: Error) => {
@@ -1090,59 +1085,36 @@ class ApplicationMain {
}
});
- ipcMain.on('show-window', () => {
- const windowController = this.windowController;
- if (windowController) {
- windowController.show();
+ IpcMainEventChannel.problemReport.handleCollectLogs((toRedact) => {
+ const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log');
+ const executable = resolveBin('mullvad-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('mullvad-problem-report');
- const args = ['collect', '--output', reportPath];
- if (toRedact.length > 0) {
- args.push('--redact', ...toRedact);
- }
+ return new Promise((resolve, reject) => {
execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
if (error) {
log.error(
`Failed to collect a problem report.
- Stdout: ${stdout.toString()}
- Stderr: ${stderr.toString()}`,
+ Stdout: ${stdout.toString()}
+ Stderr: ${stderr.toString()}`,
);
-
- event.sender.send('collect-logs-reply', requestId, {
- success: false,
- error: error.message,
- });
+ reject(error.message);
} else {
log.debug(`Problem report was written to ${reportPath}`);
-
- event.sender.send('collect-logs-reply', requestId, {
- success: true,
- reportPath,
- });
+ resolve(reportPath);
}
});
- },
- );
+ });
+ });
- ipcMain.on(
- 'send-problem-report',
- (
- event: Electron.IpcMainEvent,
- requestId: string,
- email: string,
- message: string,
- savedReport: string,
- ) => {
- const executable = resolveBin('mullvad-problem-report');
- const args = ['send', '--email', email, '--message', message, '--report', savedReport];
+ IpcMainEventChannel.problemReport.handleSendReport(({ email, message, savedReport }) => {
+ const executable = resolveBin('mullvad-problem-report');
+ const args = ['send', '--email', email, '--message', message, '--report', savedReport];
+ return new Promise((resolve, reject) => {
execFile(executable, args, { windowsHide: true }, (error, stdout, stderr) => {
if (error) {
log.error(
@@ -1150,21 +1122,14 @@ class ApplicationMain {
Stdout: ${stdout.toString()}
Stderr: ${stderr.toString()}`,
);
-
- event.sender.send('send-problem-report-reply', requestId, {
- success: false,
- error: error.message,
- });
+ reject(error.message);
} else {
log.info('Problem report was sent.');
-
- event.sender.send('send-problem-report-reply', requestId, {
- success: true,
- });
+ resolve();
}
});
- },
- );
+ });
+ });
}
private async createNewAccount(): Promise<string> {