Skip to content

Commit 0977897

Browse files
committed
feat: Update Electron to v6
1 parent 9bfa9b3 commit 0977897

6 files changed

Lines changed: 38 additions & 32 deletions

File tree

packages/neuron-wallet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@types/uuid": "3.4.4",
5959
"@types/webdriverio": "4.13.0",
6060
"devtron": "1.4.0",
61-
"electron": "5.0.7",
61+
"electron": "6.0.0",
6262
"electron-builder": "21.2.0",
6363
"electron-devtools-installer": "2.2.4",
6464
"electron-notarize": "0.1.1",

packages/neuron-wallet/src/controllers/app/index.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import path from 'path'
2-
import { dialog, shell, Menu, MenuItem, MessageBoxOptions, SaveDialogOptions, BrowserWindow } from 'electron'
2+
import {
3+
dialog,
4+
shell,
5+
Menu,
6+
MenuItem,
7+
MessageBoxOptions,
8+
MessageBoxReturnValue,
9+
SaveDialogOptions,
10+
SaveDialogReturnValue,
11+
BrowserWindow,
12+
} from 'electron'
313
import { take } from 'rxjs/operators'
414
import app from 'app'
515

@@ -99,15 +109,12 @@ export default class AppController {
99109
return WindowManager.mainWindow && winID === WindowManager.mainWindow.id
100110
}
101111

102-
public static showMessageBox(
103-
options: MessageBoxOptions,
104-
callback?: (response: number, checkboxChecked: boolean) => void
105-
) {
106-
dialog.showMessageBox(options, callback)
112+
public static showMessageBox(options: MessageBoxOptions, callback?: (returnValue: MessageBoxReturnValue) => void) {
113+
dialog.showMessageBox(options).then(callback)
107114
}
108115

109-
public static showSaveDialog(options: SaveDialogOptions, callback?: (filename?: string, bookmark?: string) => void) {
110-
dialog.showSaveDialog(options, callback)
116+
public static showSaveDialog(options: SaveDialogOptions, callback?: (returnValue: SaveDialogReturnValue) => void) {
117+
dialog.showSaveDialog(options).then(callback)
111118
}
112119

113120
public static toggleAddressBook() {

packages/neuron-wallet/src/controllers/app/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MenuItemConstructorOptions, clipboard, dialog } from 'electron'
1+
import { MenuItemConstructorOptions, clipboard, dialog, MessageBoxReturnValue } from 'electron'
22
import { bech32Address } from '@nervosnetwork/ckb-sdk-utils'
33

44
import WalletsService from 'services/wallets'
@@ -80,8 +80,8 @@ export const contextMenuTemplate: {
8080
detail: isCurrent ? i18n.t('messageBox.remove-network.alert') : '',
8181
buttons: [i18n.t('messageBox.button.confirm'), i18n.t('messageBox.button.discard')],
8282
},
83-
(btnIdx: number) => {
84-
if (btnIdx === 0) {
83+
(returnValue: MessageBoxReturnValue) => {
84+
if (returnValue.response === 0) {
8585
try {
8686
networksService.delete(id)
8787
} catch (err) {

packages/neuron-wallet/src/controllers/update.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@ export default class UpdateController {
2929

3030
autoUpdater.on('update-available', (info: UpdateInfo) => {
3131
const { version } = info
32-
dialog.showMessageBox(
33-
{
32+
dialog
33+
.showMessageBox({
3434
type: 'info',
3535
title: version,
3636
message: i18n.t('updater.updates-found-do-you-want-to-update', { version }),
3737
buttons: [i18n.t('updater.update-now'), i18n.t('common.no')],
38-
},
39-
buttonIndex => {
40-
if (buttonIndex === 0) {
38+
})
39+
.then(returnValue => {
40+
if (returnValue.response === 0) {
4141
autoUpdater.downloadUpdate()
4242
} else {
4343
this.enableSender()
4444
}
45-
}
46-
)
45+
})
4746
})
4847

4948
autoUpdater.on('update-not-available', () => {
@@ -56,16 +55,15 @@ export default class UpdateController {
5655
})
5756

5857
autoUpdater.on('update-downloaded', () => {
59-
dialog.showMessageBox(
60-
{
58+
dialog
59+
.showMessageBox({
6160
type: 'info',
6261
message: i18n.t('updater.updates-downloaded-about-to-quit-and-install'),
6362
buttons: [i18n.t('common.ok')],
64-
},
65-
() => {
63+
})
64+
.then(() => {
6665
setImmediate(() => autoUpdater.quitAndInstall())
67-
}
68-
)
66+
})
6967
})
7068
}
7169

packages/neuron-wallet/src/controllers/wallets/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'fs'
2+
import { SaveDialogReturnValue } from 'electron'
23
import AppController from 'controllers/app'
34
import WalletsService, { Wallet, WalletProperties, FileKeystoreWallet } from 'services/wallets'
45
import Keystore from 'models/keys/keystore'
@@ -270,9 +271,9 @@ export default class WalletsController {
270271
title: i18n.t('messages.save-keystore'),
271272
defaultPath: wallet.name,
272273
},
273-
(filename?: string) => {
274-
if (filename) {
275-
fs.writeFileSync(filename, JSON.stringify(keystore))
274+
(returnValue: SaveDialogReturnValue) => {
275+
if (returnValue.filePath) {
276+
fs.writeFileSync(returnValue.filePath, JSON.stringify(keystore))
276277
resolve({
277278
status: ResponseCode.Success,
278279
result: true,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7258,10 +7258,10 @@ electron-window-state@5.0.3:
72587258
jsonfile "^4.0.0"
72597259
mkdirp "^0.5.1"
72607260

7261-
electron@5.0.7:
7262-
version "5.0.7"
7263-
resolved "https://registry.yarnpkg.com/electron/-/electron-5.0.7.tgz#a48fcbd13d30f16f7d7887908b68e52156e90259"
7264-
integrity sha512-OMMz8DhatxLuBFbnW7KYcAUjflGYFn0IQEtKR0iZhMAm89FgNOd9SVbxXWAGNxvRR6C0gORXwhTh6BCqqqcR6Q==
7261+
electron@6.0.0:
7262+
version "6.0.0"
7263+
resolved "https://registry.yarnpkg.com/electron/-/electron-6.0.0.tgz#03712d461ac73cdf920b2336d6560d6c6b7f19cc"
7264+
integrity sha512-JVHj0dYtvVFrzVk1TgvrdXJSyLpdvlWNLhtG8ItYZsyg9XbCOQ9OoPfgLm04FjMzKMzEl4YIN0PfGC02MTx3PQ==
72657265
dependencies:
72667266
"@types/node" "^10.12.18"
72677267
electron-download "^4.1.0"

0 commit comments

Comments
 (0)