Browse Source

Update orderAccounts on UpdateAccount, fix handleEditName

master
Loëck Vézien 7 years ago
parent
commit
a31e6f9a6a
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 16
      package.json
  2. 17
      src/actions/accounts.js
  3. 40
      src/components/modals/SettingsAccount.js
  4. 59
      yarn.lock

16
package.json

@ -47,10 +47,10 @@
"@fortawesome/react-fontawesome": "^0.0.17",
"@ledgerhq/common": "2.3.0",
"@ledgerhq/currencies": "^2.3.0",
"@ledgerhq/hw-app-btc": "^2.2.0",
"@ledgerhq/hw-app-eth": "^2.2.0",
"@ledgerhq/hw-transport": "^2.2.0",
"@ledgerhq/hw-transport-node-hid": "^2.2.0",
"@ledgerhq/hw-app-btc": "^3.0.2",
"@ledgerhq/hw-app-eth": "^3.0.0",
"@ledgerhq/hw-transport": "^3.0.0",
"@ledgerhq/hw-transport-node-hid": "^3.0.0",
"axios": "^0.17.1",
"babel-runtime": "^6.26.0",
"bcryptjs": "^2.4.3",
@ -70,11 +70,11 @@
"object-path": "^0.11.4",
"qrcode": "^1.2.0",
"query-string": "^5.1.0",
"raven": "^2.4.0",
"raven-js": "^3.22.1",
"raven": "^2.4.1",
"raven-js": "^3.22.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-i18next": "^7.3.4",
"react-i18next": "^7.3.6",
"react-mortal": "^3.2.0",
"react-motion": "^0.5.2",
"react-qr-reader": "^2.0.1",
@ -120,7 +120,7 @@
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-plugin-flowtype": "^2.42.0",
"eslint-plugin-flowtype": "^2.43.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.6.1",

17
src/actions/accounts.js

@ -28,12 +28,6 @@ export const addAccount: AddAccount = payload => ({
payload,
})
export type UpdateAccount = Account => { type: string, payload: Account }
export const updateAccount: AddAccount = payload => ({
type: 'DB:UPDATE_ACCOUNT',
payload,
})
export type RemoveAccount = Account => { type: string, payload: Account }
export const removeAccount: RemoveAccount = payload => ({
type: 'DB:REMOVE_ACCOUNT',
@ -56,8 +50,19 @@ export const updateOrderAccounts: UpdateOrderAccounts = (orderAccounts: string)
getState,
) => {
const { accounts } = getState()
dispatch({
type: 'DB:SET_ACCOUNTS',
payload: sortAccounts(accounts, orderAccounts),
})
}
export type UpdateAccount = Account => (Function, Function) => void
export const updateAccount: UpdateAccount = payload => (dispatch, getState) => {
const { settings } = getState()
dispatch({
type: 'UPDATE_ACCOUNT',
payload,
})
dispatch(updateOrderAccounts(settings.orderAccounts))
}

40
src/components/modals/SettingsAccount.js

@ -7,11 +7,9 @@ import { push } from 'react-router-redux'
import { MODAL_SETTINGS_ACCOUNT } from 'constants'
import type { MapStateToProps } from 'react-redux'
import type { Account } from 'types/common'
import { updateOrderAccounts, updateAccount, removeAccount } from 'actions/accounts'
import { getOrderAccounts } from 'reducers/settings'
import { updateAccount, removeAccount } from 'actions/accounts'
import { setDataModal, closeModal } from 'reducers/modals'
import Box from 'components/base/Box'
@ -22,37 +20,30 @@ import Text from 'components/base/Text'
import Icon from 'components/base/Icon'
type State = {
accountName: string,
accountName: string | null,
editName: boolean,
nameHovered: boolean,
}
type Props = {
closeModal: Function,
orderAccounts: string,
push: Function,
removeAccount: Function,
setDataModal: Function,
updateAccount: Function,
updateOrderAccounts: Function,
}
const mapStateToProps: MapStateToProps<*, *, *> = state => ({
orderAccounts: getOrderAccounts(state),
})
const mapDispatchToProps = {
closeModal,
push,
removeAccount,
setDataModal,
updateAccount,
updateOrderAccounts,
}
const defaultState = {
editName: false,
accountName: '',
accountName: null,
nameHovered: false,
}
@ -72,7 +63,7 @@ class SettingsAccount extends PureComponent<Props, State> {
return {
...account,
...(accountName !== ''
...(accountName !== null
? {
name: accountName,
}
@ -107,14 +98,16 @@ class SettingsAccount extends PureComponent<Props, State> {
e.preventDefault()
const { updateAccount, setDataModal } = this.props
const { accountName } = this.state
updateAccount(account)
setDataModal(MODAL_SETTINGS_ACCOUNT, { account })
this.updateOrderAccounts()
if (accountName !== '') {
updateAccount(account)
setDataModal(MODAL_SETTINGS_ACCOUNT, { account })
this.setState({
editName: false,
})
this.setState({
editName: false,
})
}
}
handleArchiveAccount = (account: Account) => () => {
@ -127,7 +120,6 @@ class SettingsAccount extends PureComponent<Props, State> {
updateAccount({ ...account, archived: true })
}
this.updateOrderAccounts()
closeModal(MODAL_SETTINGS_ACCOUNT)
push('/')
}
@ -137,12 +129,6 @@ class SettingsAccount extends PureComponent<Props, State> {
...defaultState,
})
updateOrderAccounts() {
const { updateOrderAccounts, orderAccounts } = this.props
updateOrderAccounts(orderAccounts)
}
render() {
const { editName, nameHovered } = this.state
@ -211,4 +197,4 @@ class SettingsAccount extends PureComponent<Props, State> {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(SettingsAccount)
export default connect(null, mapDispatchToProps)(SettingsAccount)

59
yarn.lock

@ -152,29 +152,29 @@
dependencies:
querystring "^0.2.0"
"@ledgerhq/hw-app-btc@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-btc/-/hw-app-btc-2.2.0.tgz#c5c99c8974ab8df378f773c5b03052304ce3812b"
"@ledgerhq/hw-app-btc@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-btc/-/hw-app-btc-3.0.2.tgz#4bad5d65eeef3711083d681a19d58c63cc12fe02"
dependencies:
"@ledgerhq/hw-transport" "^2.2.0"
"@ledgerhq/hw-transport" "^3.0.0"
create-hash "^1.1.3"
"@ledgerhq/hw-app-eth@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-2.2.0.tgz#e8b3591ebb24565d5bacbca5d4c2a0ab99eb965a"
"@ledgerhq/hw-app-eth@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-3.0.0.tgz#0cc66865f44a1a0b6bbb5711e3585f6b58188a1c"
dependencies:
"@ledgerhq/hw-transport" "^2.2.0"
"@ledgerhq/hw-transport" "^3.0.0"
"@ledgerhq/hw-transport-node-hid@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-2.2.0.tgz#da24caf79401f4d3fd841a724e71928c841ae84c"
"@ledgerhq/hw-transport-node-hid@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-3.0.0.tgz#eda95b99fa5d43e8703dbc0682fdb2a386a0dd25"
dependencies:
"@ledgerhq/hw-transport" "^2.2.0"
"@ledgerhq/hw-transport" "^3.0.0"
node-hid "^0.7.2"
"@ledgerhq/hw-transport@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-2.2.0.tgz#32d6374e6cfacbb4b9b0a545cdd2f6bf3d64623f"
"@ledgerhq/hw-transport@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-3.0.0.tgz#0a191626f906aa8b786b762a0e08641956c17ede"
dependencies:
events "^1.1.1"
@ -3746,9 +3746,9 @@ eslint-module-utils@^2.1.1:
debug "^2.6.8"
pkg-dir "^1.0.0"
eslint-plugin-flowtype@^2.42.0:
version "2.42.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.42.0.tgz#7fcc98df4ed9482a22ac10ba4ca48d649c4c733a"
eslint-plugin-flowtype@^2.43.0:
version "2.43.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.43.0.tgz#47cdac5f01cda53f1c3e8477f0c83fee66a1606e"
dependencies:
lodash "^4.15.0"
@ -5916,10 +5916,6 @@ lru-cache@^4.0.1, lru-cache@^4.1.1:
pseudomap "^1.0.2"
yallist "^2.1.2"
lsmod@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/lsmod/-/lsmod-1.0.0.tgz#9a00f76dca36eb23fa05350afe1b585d4299e64b"
macaddress@^0.2.8:
version "0.2.8"
resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"
@ -7433,16 +7429,15 @@ range-parser@^1.0.3, range-parser@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
raven-js@^3.22.1:
version "3.22.1"
resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.22.1.tgz#1117f00dfefaa427ef6e1a7d50bbb1fb998a24da"
raven-js@^3.22.2:
version "3.22.2"
resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.22.2.tgz#85785928ebd664049e54efd0db8ff28da0cbb374"
raven@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/raven/-/raven-2.4.0.tgz#49b7d5f838e5893f31dd72f82d05a35e42203f60"
raven@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/raven/-/raven-2.4.1.tgz#7a6a6ff1c42d0a3892308f44c94273e7f88677fd"
dependencies:
cookie "0.3.1"
lsmod "1.0.0"
md5 "^2.2.1"
stack-trace "0.0.9"
timed-out "4.0.1"
@ -7531,9 +7526,9 @@ react-html-attributes@^1.3.0:
dependencies:
html-element-attributes "^1.0.0"
react-i18next@^7.3.4:
version "7.3.4"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-7.3.4.tgz#d5932d47ac7f0d723eecef492ea97b7232673706"
react-i18next@^7.3.6:
version "7.3.6"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-7.3.6.tgz#3e4fdd0be7735aa53343720684247ba7f6cfd51a"
dependencies:
hoist-non-react-statics "2.3.1"
html-parse-stringify2 "2.0.1"

Loading…
Cancel
Save