From b438509652177c887eef779eabc77468b1e85cd1 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 2 Aug 2019 17:32:44 +0800 Subject: [PATCH] fix(neuron-wallet): set current wallet empty if wallet list is empty --- packages/neuron-wallet/src/services/wallets.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/neuron-wallet/src/services/wallets.ts b/packages/neuron-wallet/src/services/wallets.ts index 9e05071c2a..aa305e5c8a 100644 --- a/packages/neuron-wallet/src/services/wallets.ts +++ b/packages/neuron-wallet/src/services/wallets.ts @@ -245,6 +245,8 @@ export default class WalletService { if (currentID === id) { if (newWallets.length > 0) { this.setCurrent(newWallets[0].id) + } else { + this.setCurrent('') } } @@ -258,9 +260,11 @@ export default class WalletService { throw new IsRequired('ID') } - const wallet = this.get(id) - if (!wallet) { - throw new WalletNotFound(id) + if (id !== '') { + const wallet = this.get(id) + if (!wallet) { + throw new WalletNotFound(id) + } } this.listStore.writeSync(this.currentWalletKey, id)