Skip to content

Commit

Permalink
fix(neuron-ui): set current wallet to empty when all wallets are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Oct 15, 2019
1 parent 3d1ef6f commit f146e34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/neuron-ui/src/states/initStates/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { addresses, currentWallet } from 'services/localCache'

export const emptyWallet: State.Wallet = {
name: '',
id: '',
balance: '0',
addresses: [],
}

const wallet = currentWallet.load()

export const walletState: State.Wallet = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
backupWallet as backupRemoteWallet,
showErrorMessage,
} from 'services/remote'
import initStates from 'states/initStates'
import { emptyWallet } from 'states/initStates/wallet'
import { WalletWizardPath } from 'components/WalletWizard'
import i18n from 'utils/i18n'
import { wallets as walletsCache, currentWallet as currentWalletCache } from 'services/localCache'
Expand All @@ -26,7 +26,7 @@ import { addNotification, addPopup } from './app'
export const updateCurrentWallet = () => (dispatch: StateDispatch, history: any) => {
getCurrentWallet().then(res => {
if (res.status === 1) {
const payload = res.result || initStates.wallet
const payload = res.result || emptyWallet
if (!payload || !payload.id) {
history.push(`${Routes.WalletWizard}${WalletWizardPath.Welcome}`)
}
Expand Down

0 comments on commit f146e34

Please sign in to comment.