diff options
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/index.ts | 89 |
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> { |
