Browse Source

AccountSettings type, ability to adjust minConfirmations

master
meriadec 7 years ago
parent
commit
cb687b7c74
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 2
      src/components/AccountPage.js
  2. 3
      src/components/SelectAccount/stories.js
  3. 33
      src/components/modals/SettingsAccount.js
  4. 6
      src/types/common.js

2
src/components/AccountPage.js

@ -25,7 +25,7 @@ import TransactionsList from 'components/TransactionsList'
type Props = {
t: T,
account: Account,
account?: Account,
openModal: Function,
}

3
src/components/SelectAccount/stories.js

@ -22,6 +22,9 @@ const accounts = [...Array(20)].map(() => ({
path: '',
transactions: [],
unit: getDefaultUnitByCoinType(0),
settings: {
minConfirmations: 2,
},
}))
type State = {

33
src/components/modals/SettingsAccount.js

@ -18,9 +18,11 @@ import Input from 'components/base/Input'
import Modal, { ModalBody } from 'components/base/Modal'
import Text from 'components/base/Text'
import Icon from 'components/base/Icon'
import Label from 'components/base/Label'
type State = {
accountName: string | null,
minConfirmations: number | null,
editName: boolean,
nameHovered: boolean,
}
@ -44,6 +46,7 @@ const mapDispatchToProps = {
const defaultState = {
editName: false,
accountName: null,
minConfirmations: null,
nameHovered: false,
}
@ -57,7 +60,7 @@ class SettingsAccount extends PureComponent<Props, State> {
}
getAccount(data: Object) {
const { accountName } = this.state
const { accountName, minConfirmations } = this.state
const account = get(data, 'account', {})
@ -68,6 +71,10 @@ class SettingsAccount extends PureComponent<Props, State> {
name: accountName,
}
: {}),
settings: {
...account.settings,
minConfirmations: minConfirmations || account.settings.minConfirmations,
},
}
}
@ -76,6 +83,20 @@ class SettingsAccount extends PureComponent<Props, State> {
nameHovered: state,
})
handleChangeMinConfirmations = account => minConfirmations => {
const { updateAccount } = this.props
this.setState({ minConfirmations })
window.requestAnimationFrame(() => {
updateAccount({
...account,
settings: {
...account.settings,
minConfirmations,
},
})
})
}
handleEditName = (state: boolean) => () =>
this.setState({
nameHovered: false,
@ -179,6 +200,16 @@ class SettingsAccount extends PureComponent<Props, State> {
</Box>
)}
</Box>
<Box>
<Label>{'Minimum confirmations'}</Label>
<Input
type="number"
min={1}
max={100}
value={account.settings.minConfirmations}
onChange={this.handleChangeMinConfirmations(account)}
/>
</Box>
<Box horizontal grow alignItems="flex-end" flow={2}>
<Box grow>
<Button onClick={this.handleArchiveAccount(account)}>

6
src/types/common.js

@ -18,10 +18,15 @@ export type Transaction = {
balance: number,
hash: string,
receivedAt: string,
confirmations: number,
}
// -------------------- Accounts
export type AccountSettings = {
minConfirmations: number,
}
export type Account = {
address: string,
addresses: Array<string>,
@ -35,6 +40,7 @@ export type Account = {
path: string,
transactions: Array<Transaction>,
unit: Unit,
settings: AccountSettings,
}
export type Accounts = Array<Account>

Loading…
Cancel
Save