Skip to content

Commit

Permalink
Merge pull request #711 from blockchain/feature/reset-link-step
Browse files Browse the repository at this point in the history
Sfox fix
  • Loading branch information
plondon committed Jun 29, 2018
2 parents d22db1b + 93ce79b commit 463ba50
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ui from 'redux-ui'
import Link from './template'
import { actions, selectors } from 'data'
import { formValueSelector } from 'redux-form'
import { merge, path, append } from 'ramda'
import { merge, path, append, prop, head } from 'ramda'
import { Remote } from 'blockchain-wallet-v4/src'

class LinkContainer extends Component {
Expand Down Expand Up @@ -44,6 +44,11 @@ class LinkContainer extends Component {
}
}

componentWillUnmount () {
this.props.updateUI({ toggleManual: false, selectBank: false, microDeposits: false, microStep: 'welcome', busy: false })
this.props.sfoxDataActions.wipeBankAccounts()
}

onSetBankAccount (data) {
const bankChoice = merge(data, {token: this.state.token})
this.props.sfoxFrontendActions.setBankAccount(bankChoice)
Expand Down Expand Up @@ -75,8 +80,8 @@ class LinkContainer extends Component {
const { showModal } = this.props.modalActions

let awaitingDeposits = false
if (Remote.Success.is(accounts) && accounts.data) {
awaitingDeposits = accounts.data[0] && accounts.data[0]['status'] === 'pending'
if (Remote.Success.is(accounts)) {
awaitingDeposits = prop('status', head(accounts.getOrElse())) === 'pending'
}

const { sfoxBusy, err } = linkStatus.cata({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ const BankLink = (props) => {
handleAccountType={handleAccountType}
{...props}
/>
} else if (bankAccounts) {
return <BankAccounts data={bankAccounts.data} onSetBankAccount={onSetBankAccount} onBankSelection={handleBankSelection} handleNameChange={onNameChange} />
} else if (Remote.Success.is(bankAccounts)) {
return <BankAccounts data={bankAccounts.getOrElse([])} onSetBankAccount={onSetBankAccount} onBankSelection={handleBankSelection} handleNameChange={onNameChange} />
} else if (ui.microDeposits) {
return <MicroDeposits onStep={microStep} />
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const UPLOAD_FAILURE = '@CORE.UPLOAD_FAILURE'
export const GET_BANK_ACCOUNTS = '@CORE.GET_BANK_ACCOUNTS'
export const GET_BANK_ACCOUNTS_SUCCESS = '@CORE.GET_BANK_ACCOUNTS_SUCCESS'
export const GET_BANK_ACCOUNTS_FAILURE = '@CORE.GET_BANK_ACCOUNTS_FAILURE'
export const WIPE_BANK_ACCOUNTS = '@CORE.WIPE_BANK_ACCOUNTS'

export const SET_BANK_ACCOUNT = '@CORE.SET_BANK_ACCOUNT'
export const SET_BANK_ACCOUNT_SUCCESS = '@CORE.SET_BANK_ACCOUNT_SUCCESS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const uploadFailure = (error) => ({ type: AT.UPLOAD_FAILURE, payload: err
export const getBankAccounts = (token) => ({ type: AT.GET_BANK_ACCOUNTS, payload: token })
export const getBankAccountsSuccess = (accounts) => ({ type: AT.GET_BANK_ACCOUNTS_SUCCESS, payload: accounts })
export const getBankAccountsFailure = (error) => ({ type: AT.GET_BANK_ACCOUNTS_FAILURE, payload: error })
export const wipeBankAccounts = () => ({ type: AT.WIPE_BANK_ACCOUNTS })

export const setBankAccount = (data) => ({ type: AT.SET_BANK_ACCOUNT, payload: data })
export const setBankAccountSuccess = () => ({ type: AT.SET_BANK_ACCOUNT_SUCCESS })
Expand Down
3 changes: 3 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/data/sfox/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const sfoxReducer = (state = INITIAL_STATE, action) => {
case AT.GET_BANK_ACCOUNTS_FAILURE: {
return assoc('bankAccounts', Remote.Failure(payload), state)
}
case AT.WIPE_BANK_ACCOUNTS: {
return assoc('bankAccounts', Remote.NotAsked, state)
}
case AT.SET_BANK_ACCOUNT_SUCCESS: {
return state
}
Expand Down

0 comments on commit 463ba50

Please sign in to comment.