From e1d42f95d9c662bd4ffc8221bc4e5b9b96a095a6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Jan 2020 09:46:42 -0500 Subject: [PATCH] updates to support electron 6 --- src/electron/baseMenu.ts | 23 +++++++++++-------- .../services/electronPlatformUtils.service.ts | 12 +++++----- src/electron/updater.main.ts | 12 +++++----- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/electron/baseMenu.ts b/src/electron/baseMenu.ts index 3e7e3d3c59..de08e4da68 100644 --- a/src/electron/baseMenu.ts +++ b/src/electron/baseMenu.ts @@ -48,7 +48,7 @@ export class BaseMenu { { type: 'separator' }, { label: this.i18nService.t('selectAll'), - role: 'selectall', + role: 'selectAll', }, ], }; @@ -56,15 +56,18 @@ export class BaseMenu { this.viewSubMenuItemOptions = [ { label: this.i18nService.t('zoomIn'), - role: 'zoomin', accelerator: 'CmdOrCtrl+=', + role: 'zoomIn', + accelerator: 'CmdOrCtrl+=', }, { label: this.i18nService.t('zoomOut'), - role: 'zoomout', accelerator: 'CmdOrCtrl+-', + role: 'zoomOut', + accelerator: 'CmdOrCtrl+-', }, { label: this.i18nService.t('resetZoom'), - role: 'resetzoom', accelerator: 'CmdOrCtrl+0', + role: 'resetZoom', + accelerator: 'CmdOrCtrl+0', }, { type: 'separator' }, { @@ -74,11 +77,11 @@ export class BaseMenu { { type: 'separator' }, { label: this.i18nService.t('reload'), - role: 'forcereload', + role: 'forceReload', }, { label: this.i18nService.t('toggleDevTools'), - role: 'toggledevtools', + role: 'toggleDevTools', accelerator: 'F12', }, ]; @@ -111,7 +114,7 @@ export class BaseMenu { }, { label: this.i18nService.t('hideOthers'), - role: 'hideothers', + role: 'hideOthers', }, { label: this.i18nService.t('showAll'), @@ -159,7 +162,7 @@ export class BaseMenu { { type: 'separator' }, { label: this.i18nService.t('selectAll'), - role: 'selectall', + role: 'selectAll', }, ]); @@ -190,7 +193,7 @@ export class BaseMenu { { type: 'separator' }, { label: this.i18nService.t('selectAll'), - role: 'selectall', + role: 'selectAll', }, ]); @@ -210,7 +213,7 @@ export class BaseMenu { { type: 'separator' }, { label: this.i18nService.t('selectAll'), - role: 'selectall', + role: 'selectAll', }, ]); diff --git a/src/electron/services/electronPlatformUtils.service.ts b/src/electron/services/electronPlatformUtils.service.ts index 877cbfcf4f..ad08b170e5 100644 --- a/src/electron/services/electronPlatformUtils.service.ts +++ b/src/electron/services/electronPlatformUtils.service.ts @@ -114,9 +114,9 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService { remote.dialog.showSaveDialog(remote.getCurrentWindow(), { defaultPath: fileName, showsTagField: false, - }, (path) => { - if (path != null) { - fs.writeFile(path, Buffer.from(blobData), (err) => { + }).then((ret) => { + if (ret.filePath != null) { + fs.writeFile(ret.filePath, Buffer.from(blobData), (err) => { // error check? }); } @@ -147,14 +147,14 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService { }); } - showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string): + async showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string): Promise { const buttons = [confirmText == null ? this.i18nService.t('ok') : confirmText]; if (cancelText != null) { buttons.push(cancelText); } - const result = remote.dialog.showMessageBox(remote.getCurrentWindow(), { + const result = await remote.dialog.showMessageBox(remote.getCurrentWindow(), { type: type, title: title, message: title, @@ -165,7 +165,7 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService { noLink: true, }); - return Promise.resolve(result === 0); + return Promise.resolve(result.response === 0); } eventTrack(action: string, label?: string, options?: any) { diff --git a/src/electron/updater.main.ts b/src/electron/updater.main.ts index 59f61aaf1d..f09ca46847 100644 --- a/src/electron/updater.main.ts +++ b/src/electron/updater.main.ts @@ -50,14 +50,14 @@ export class UpdaterMain { this.doingUpdateCheck = true; }); - autoUpdater.on('update-available', () => { + autoUpdater.on('update-available', async () => { if (this.doingUpdateCheckWithFeedback) { if (this.windowMain.win == null) { this.reset(); return; } - const result = dialog.showMessageBox(this.windowMain.win, { + const result = await dialog.showMessageBox(this.windowMain.win, { type: 'info', title: this.i18nService.t(this.projectName) + ' - ' + this.i18nService.t('updateAvailable'), message: this.i18nService.t('updateAvailable'), @@ -68,7 +68,7 @@ export class UpdaterMain { noLink: true, }); - if (result === 0) { + if (result.response === 0) { autoUpdater.downloadUpdate(); } else { this.reset(); @@ -89,7 +89,7 @@ export class UpdaterMain { this.reset(); }); - autoUpdater.on('update-downloaded', (info) => { + autoUpdater.on('update-downloaded', async (info) => { if (this.onUpdateDownloaded != null) { this.onUpdateDownloaded(); } @@ -98,7 +98,7 @@ export class UpdaterMain { return; } - const result = dialog.showMessageBox(this.windowMain.win, { + const result = await dialog.showMessageBox(this.windowMain.win, { type: 'info', title: this.i18nService.t(this.projectName) + ' - ' + this.i18nService.t('restartToUpdate'), message: this.i18nService.t('restartToUpdate'), @@ -109,7 +109,7 @@ export class UpdaterMain { noLink: true, }); - if (result === 0) { + if (result.response === 0) { autoUpdater.quitAndInstall(false, true); } });