Skip to content

Commit

Permalink
fix: Optimize the error of update Neuron (nervosnetwork#3002)
Browse files Browse the repository at this point in the history
* fix: issue 336

* fix: AlertDialog

---------

Co-authored-by: Chen Yu <keithwhisper@gmail.com>
  • Loading branch information
devchenyan and Keith-CY authored Jan 5, 2024
1 parent 745877a commit 1eea695
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/neuron-ui/src/widgets/AlertDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const AlertDialog = ({
title,
message,
type,
onClose,
onOk,
onCancel,
action,
Expand All @@ -24,14 +23,13 @@ const AlertDialog = ({
title?: string
message?: string
type: AlertType
onClose?: () => void
onOk?: () => void
onCancel?: () => void
action?: Action
}) => {
const [t] = useTranslation()
const dialogRef = useRef<HTMLDialogElement | null>(null)
useDialog({ show, dialogRef, onClose: onClose || (() => {}) })
useDialog({ show, dialogRef, onClose: onCancel || (() => {}) })
const actions = useMemo<('cancel' | 'ok')[]>(() => {
if (action) {
return action === 'all' ? ['cancel', 'ok'] : [action]
Expand Down
8 changes: 7 additions & 1 deletion packages/neuron-wallet/src/controllers/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { autoUpdater, UpdateInfo, CancellationToken, ProgressInfo } from 'electron-updater'
import { t } from 'i18next'
import AppUpdaterSubject, { AppUpdater } from '../models/subjects/app-updater'
import logger from '../utils/logger'

Expand Down Expand Up @@ -64,11 +65,16 @@ export default class UpdateController {

autoUpdater.on('error', error => {
UpdateController.isChecking = false
let errorMsg = error == null ? 'unknown' : (error.stack || error).toString()
logger.error('Update Controller:\t autoUpdater fail:', errorMsg)
if (errorMsg.includes('net::ERR_INTERNET_DISCONNECTED') || errorMsg.includes('net::ERR_TIMED_OUT')) {
errorMsg = t('messages.could-not-connect-service')
}
this.notify({
version: '',
releaseDate: '',
releaseNotes: '',
errorMsg: error == null ? 'unknown' : (error.stack || error).toString(),
errorMsg,
})
})

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default {
'no-exist-ckb-node-data':
'{{path}} has no CKB Node config and storage, press confirm to synchronize from scratch',
'light-client-sudt-acp-error': "Light client mode doesn't support sending assets to other's asset account",
'could-not-connect-service': 'Could not connect to the service, please try again later.',
},
messageBox: {
button: {
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/locales/zh-tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default {
'target-lock-error': 'CKB 資產只能轉賬到 secp256k1 或者 acp 地址',
'no-exist-ckb-node-data': '{{path}} 目錄下沒有找到 CKB Node 配置和數據, 點擊確認重新同步',
'light-client-sudt-acp-error': '輕節點模式不支持發送資產給其他用戶的資產賬戶',
'could-not-connect-service': '無法連接到服務,請稍後再試。',
},
messageBox: {
button: {
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default {
'target-lock-error': 'CKB 资产只能转账到 secp256k1 或者 acp 地址',
'no-exist-ckb-node-data': '{{path}} 目录下没有找到 CKB Node 配置和数据, 点击确认重新同步',
'light-client-sudt-acp-error': '轻节点模式不支持发送资产给其他用户的资产账户',
'could-not-connect-service': '无法连接到服务,请稍后再试。',
},
messageBox: {
button: {
Expand Down

0 comments on commit 1eea695

Please sign in to comment.