Skip to content

Commit

Permalink
Make ImportAccountsSelectionModal compatible with React 18 Strict Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Oct 3, 2022
1 parent 10d9868 commit 22380a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { AlertBox } from 'app/components/AlertBox'
Expand Down Expand Up @@ -61,13 +61,6 @@ export function ImportAccountsSelectionModal(props: ImportAccountsSelectionModal
: walletActions.openWalletFromMnemonic(),
)
}

useEffect(() => {
return () => {
dispatch(importAccountsActions.clear())
}
}, [dispatch])

const cancelDisabled = importAccounts.step === ImportAccountsStep.Done || error ? false : true
const confirmDisabled = importAccounts.step !== ImportAccountsStep.Done || selectedAccounts.length === 0

Expand Down
3 changes: 3 additions & 0 deletions src/app/state/wallet/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { walletActions } from '.'
import { transactionActions } from '../transaction'
import { getBalance, rootWalletSaga, walletSaga } from './saga'
import { AddWalletPayload, WalletType } from './types'
import { importAccountsActions } from '../importaccounts'

describe('Wallet Sagas', () => {
const validPrivateKeyHex =
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('Wallet Sagas', () => {
.withState(state)
.dispatch(walletActions.openWalletFromMnemonic())
.fork(walletSaga)
.put(importAccountsActions.clear())
.put(
walletActions.addWallet({
address: 'oasis1qq2vzcvxn0js5unsch5me2xz4kr43vcasv0d5eq4',
Expand Down Expand Up @@ -91,6 +93,7 @@ describe('Wallet Sagas', () => {
.withState(state)
.dispatch(walletActions.openWalletsFromLedger())
.fork(walletSaga)
.put(importAccountsActions.clear())
.put.actionType(walletActions.selectWallet.type)
.silentRun(50)
})
Expand Down
3 changes: 3 additions & 0 deletions src/app/state/wallet/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { call, delay, fork, put, select, take, takeEvery } from 'typed-redux-sag
import { selectSelectedAccounts } from 'app/state/importaccounts/selectors'

import { walletActions } from '.'
import { importAccountsActions } from '../importaccounts'
import { ImportAccountsListAccount } from '../importaccounts/types'
import { getOasisNic } from '../network/saga'
import { transactionActions } from '../transaction'
Expand Down Expand Up @@ -57,6 +58,7 @@ function* getWalletByAddress(address: string) {
*/
export function* openWalletsFromLedger() {
const accounts: ImportAccountsListAccount[] = yield* select(selectSelectedAccounts)
yield* put(importAccountsActions.clear())
for (const account of accounts) {
yield* put(
walletActions.addWallet({
Expand Down Expand Up @@ -92,6 +94,7 @@ export function* openWalletFromPrivateKey({ payload: privateKey }: PayloadAction

export function* openWalletFromMnemonic() {
const accounts: ImportAccountsListAccount[] = yield* select(selectSelectedAccounts)
yield* put(importAccountsActions.clear())
for (const account of accounts) {
yield* put(
walletActions.addWallet({
Expand Down

0 comments on commit 22380a7

Please sign in to comment.