Browse Source

Fix countervalues to always reload based on the selector

master
Gaëtan Renaudeau 7 years ago
parent
commit
99acefb311
  1. 2
      package.json
  2. 23
      src/components/SettingsPage/sections/Currencies.js
  3. 26
      src/components/SettingsPage/sections/Display.js
  4. 19
      src/components/modals/AddAccount/index.js
  5. 6
      yarn.lock

2
package.json

@ -42,7 +42,7 @@
"@ledgerhq/hw-transport": "^4.12.0",
"@ledgerhq/hw-transport-node-hid": "^4.12.0",
"@ledgerhq/ledger-core": "^1.2.0",
"@ledgerhq/live-common": "^2.8.1",
"@ledgerhq/live-common": "^2.9.1",
"axios": "^0.18.0",
"babel-runtime": "^6.26.0",
"bcryptjs": "^2.4.3",

23
src/components/SettingsPage/sections/Currencies.js

@ -15,7 +15,6 @@ import type { Settings, CurrencySettings, T } from 'types/common'
import { counterValueCurrencySelector } from 'reducers/settings'
import { currenciesSelector } from 'reducers/accounts'
import CounterValues from 'helpers/countervalues'
import SelectCurrency from 'components/SelectCurrency'
import StepperNumber from 'components/base/StepperNumber'
@ -138,21 +137,13 @@ class TabCurrencies extends PureComponent<Props, State> {
/>
<Body>
<Row title="Exchange" desc="The exchange to use">
<CounterValues.PollingConsumer>
{polling => (
// TODO move to a dedicated "row" component
<ExchangeSelect
from={currency}
to={counterValueCurrency}
exchangeId={exchange}
onChange={exchange => {
this.handleChangeExchange(exchange)
polling.poll()
}}
style={{ minWidth: 200 }}
/>
)}
</CounterValues.PollingConsumer>
<ExchangeSelect
from={currency}
to={counterValueCurrency}
exchangeId={exchange}
onChange={this.handleChangeExchange}
style={{ minWidth: 200 }}
/>
</Row>
<Row
title={t('settings:currencies.confirmationsToSpend')}

26
src/components/SettingsPage/sections/Display.js

@ -10,7 +10,6 @@ import Select from 'components/base/Select'
import RadioGroup from 'components/base/RadioGroup'
import IconDisplay from 'icons/Display'
import languageKeys from 'config/languages'
import CounterValues from 'helpers/countervalues'
import regionsByKey from 'helpers/regions.json'
@ -135,22 +134,15 @@ class TabProfile extends PureComponent<Props, State> {
title={t('settings:display.counterValue')}
desc={t('settings:display.counterValueDesc')}
>
<CounterValues.PollingConsumer>
{polling => (
<Select
style={{ minWidth: 250 }}
small
onChange={item => {
this.handleChangeCounterValue(item)
polling.poll()
}}
itemToString={item => (item ? item.name : '')}
renderSelected={item => item && item.name}
items={fiats}
value={cachedCounterValue}
/>
)}
</CounterValues.PollingConsumer>
<Select
style={{ minWidth: 250 }}
small
onChange={this.handleChangeCounterValue}
itemToString={item => (item ? item.name : '')}
renderSelected={item => item && item.name}
items={fiats}
value={cachedCounterValue}
/>
</Row>
<Row title={t('settings:display.language')} desc={t('settings:display.languageDesc')}>
<Select

19
src/components/modals/AddAccount/index.js

@ -28,7 +28,6 @@ import Button from 'components/base/Button'
import Modal, { ModalContent, ModalTitle, ModalFooter, ModalBody } from 'components/base/Modal'
import StepConnectDevice from 'components/modals/StepConnectDevice'
import { getBridgeForCurrency } from 'bridge'
import CounterValues from 'helpers/countervalues'
import StepCurrency from './01-step-currency'
import StepImport from './03-step-import'
@ -62,7 +61,6 @@ type Props = {
closeModal: Function,
t: T,
updateAccount: Function,
counterValuesPolling: *,
}
type State = {
@ -173,8 +171,6 @@ class AddAccountModal extends PureComponent<Props, State> {
selectedAccounts.forEach(a => addAccount({ ...a, archived: false }))
this.setState({ selectedAccounts: [] })
closeModal(MODAL_ADD_ACCOUNT)
this.props.counterValuesPolling.poll()
this.props.counterValuesPolling.flush()
}
handleNextStep = () => {
@ -298,17 +294,4 @@ class AddAccountModal extends PureComponent<Props, State> {
)
}
}
// FIXME This is kinda ugly architecture right now.
// I think we should delegate more work to individual steps
// e.g. each step is responsible to connect to redux, not at top level.
const AddAccountModalAndCounterValues = props => (
<CounterValues.PollingConsumer>
{cvPolling => <AddAccountModal counterValuesPolling={cvPolling} {...props} />}
</CounterValues.PollingConsumer>
)
export default compose(connect(mapStateToProps, mapDispatchToProps), translate())(
AddAccountModalAndCounterValues,
)
export default compose(connect(mapStateToProps, mapDispatchToProps), translate())(AddAccountModal)

6
yarn.lock

@ -1460,9 +1460,9 @@
npm "^5.7.1"
prebuild-install "^2.2.2"
"@ledgerhq/live-common@^2.8.1":
version "2.8.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.8.1.tgz#7b1ad72679c899d6f5abc911b9fe36dc08ccf8a7"
"@ledgerhq/live-common@^2.9.1":
version "2.9.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.9.1.tgz#fdf7e348cb72622f7ef703d8d70534e3ea4ce242"
dependencies:
axios "^0.18.0"
invariant "^2.2.2"

Loading…
Cancel
Save