Browse Source

Merge pull request #434 from gre/remove-archived

remove archived flag. future impl will differ
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
503e1490f0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 2
      src/bridge/EthereumJSBridge.js
  3. 1
      src/bridge/RippleJSBridge.js
  4. 1
      src/bridge/makeMockBridge.js
  5. 4
      src/components/AccountPage/index.js
  6. 11
      src/components/DashboardPage/index.js
  7. 4
      src/components/QRCodeExporter.js
  8. 7
      src/components/SelectAccount/index.js
  9. 6
      src/components/SideBar/index.js
  10. 9
      src/components/modals/ImportAccounts/index.js
  11. 4
      src/components/modals/Send/SendModalBody.js
  12. 28
      src/reducers/accounts.js
  13. 4
      src/reducers/bridgeSync.js
  14. 6
      yarn.lock

2
package.json

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

2
src/bridge/EthereumJSBridge.js

@ -146,7 +146,6 @@ const EthereumBridge: WalletBridge<Transaction> = {
name: 'New Account', name: 'New Account',
balance, balance,
blockHeight: currentBlock.height, blockHeight: currentBlock.height,
archived: false,
index, index,
currency, currency,
operations: [], operations: [],
@ -171,7 +170,6 @@ const EthereumBridge: WalletBridge<Transaction> = {
name: address.slice(32), name: address.slice(32),
balance, balance,
blockHeight: currentBlock.height, blockHeight: currentBlock.height,
archived: false,
index, index,
currency, currency,
operations: [], operations: [],

1
src/bridge/RippleJSBridge.js

@ -254,7 +254,6 @@ const RippleJSBridge: WalletBridge<Transaction> = {
operations: [], operations: [],
pendingOperations: [], pendingOperations: [],
unit: currency.units[0], unit: currency.units[0],
archived: false,
lastSyncDate: new Date(), lastSyncDate: new Date(),
} }
account.operations = transactions.map(txToOperation(account)) account.operations = transactions.map(txToOperation(account))

1
src/bridge/makeMockBridge.js

@ -91,7 +91,6 @@ function makeMockBridge(opts?: Opts): WalletBridge<*> {
currency, currency,
}) })
account.unit = currency.units[0] account.unit = currency.units[0]
account.archived = false
if (!unsubscribed) next(account) if (!unsubscribed) next(account)
} }
if (!unsubscribed) complete() if (!unsubscribed) complete()

4
src/components/AccountPage/index.js

@ -14,7 +14,7 @@ import type { T } from 'types/common'
import { darken } from 'styles/helpers' import { darken } from 'styles/helpers'
import { getAccountById } from 'reducers/accounts' import { accountSelector } from 'reducers/accounts'
import { counterValueCurrencySelector, localeSelector } from 'reducers/settings' import { counterValueCurrencySelector, localeSelector } from 'reducers/settings'
import { openModal } from 'reducers/modals' import { openModal } from 'reducers/modals'
@ -50,7 +50,7 @@ const ButtonSettings = styled(Button).attrs({
` `
const mapStateToProps = (state, props) => ({ const mapStateToProps = (state, props) => ({
account: getAccountById(state, props.match.params.id), account: accountSelector(state, { accountId: props.match.params.id }),
counterValue: counterValueCurrencySelector(state), counterValue: counterValueCurrencySelector(state),
settings: localeSelector(state), settings: localeSelector(state),
}) })

11
src/components/DashboardPage/index.js

@ -6,13 +6,14 @@ import { translate } from 'react-i18next'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { push } from 'react-router-redux' import { push } from 'react-router-redux'
import chunk from 'lodash/chunk' import chunk from 'lodash/chunk'
import { createStructuredSelector } from 'reselect'
import type { Account, Currency } from '@ledgerhq/live-common/lib/types' import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common' import type { T } from 'types/common'
import { colors } from 'styles/theme' import { colors } from 'styles/theme'
import { getVisibleAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { counterValueCurrencySelector, localeSelector } from 'reducers/settings' import { counterValueCurrencySelector, localeSelector } from 'reducers/settings'
import { updateOrderAccounts } from 'actions/accounts' import { updateOrderAccounts } from 'actions/accounts'
@ -30,10 +31,10 @@ import AccountCard from './AccountCard'
import AccountsOrder from './AccountsOrder' import AccountsOrder from './AccountsOrder'
import EmptyState from './EmptyState' import EmptyState from './EmptyState'
const mapStateToProps = state => ({ const mapStateToProps = createStructuredSelector({
accounts: getVisibleAccounts(state), accounts: accountsSelector,
counterValue: counterValueCurrencySelector(state), counterValue: counterValueCurrencySelector,
locale: localeSelector(state), locale: localeSelector,
}) })
const mapDispatchToProps = { const mapDispatchToProps = {

4
src/components/QRCodeExporter.js

@ -4,7 +4,7 @@ import React, { PureComponent } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import type { State } from 'reducers' import type { State } from 'reducers'
import { getVisibleAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import QRCode from './base/QRCode' import QRCode from './base/QRCode'
// encode the app state to export into an array of chunks for the mobile app to understand. // encode the app state to export into an array of chunks for the mobile app to understand.
@ -15,7 +15,7 @@ function makeChunks(state: State): Array<string> {
const desktopVersion = __APP_VERSION__ const desktopVersion = __APP_VERSION__
const data = [ const data = [
['meta', chunksFormatVersion, 'desktop', desktopVersion], ['meta', chunksFormatVersion, 'desktop', desktopVersion],
...getVisibleAccounts(state).map(account => [ ...accountsSelector(state).map(account => [
'account', 'account',
account.id, account.id,
account.name, account.name,

7
src/components/SelectAccount/index.js

@ -4,20 +4,21 @@ import React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { translate } from 'react-i18next' import { translate } from 'react-i18next'
import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react' import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react'
import { createStructuredSelector } from 'reselect'
import type { Account } from '@ledgerhq/live-common/lib/types' import type { Account } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common' import type { T } from 'types/common'
import type { Option } from 'components/base/Select' import type { Option } from 'components/base/Select'
import { getVisibleAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import Select from 'components/base/Select' import Select from 'components/base/Select'
import FormattedVal from 'components/base/FormattedVal' import FormattedVal from 'components/base/FormattedVal'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Text from 'components/base/Text' import Text from 'components/base/Text'
const mapStateToProps = state => ({ const mapStateToProps = createStructuredSelector({
accounts: getVisibleAccounts(state), accounts: accountsSelector,
}) })
const renderOption = a => { const renderOption = a => {

6
src/components/SideBar/index.js

@ -13,7 +13,7 @@ import { MODAL_SEND, MODAL_RECEIVE } from 'config/constants'
import type { T } from 'types/common' import type { T } from 'types/common'
import { openModal } from 'reducers/modals' import { openModal } from 'reducers/modals'
import { getVisibleAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { getUpdateStatus } from 'reducers/update' import { getUpdateStatus } from 'reducers/update'
import type { UpdateStatus } from 'reducers/update' import type { UpdateStatus } from 'reducers/update'
@ -62,7 +62,7 @@ type Props = {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
accounts: getVisibleAccounts(state), accounts: accountsSelector(state),
updateStatus: getUpdateStatus(state), updateStatus: getUpdateStatus(state),
}) })
@ -125,7 +125,7 @@ class SideBar extends PureComponent<Props> {
} }
const AccountsList = connect(state => ({ const AccountsList = connect(state => ({
accounts: getVisibleAccounts(state), accounts: accountsSelector(state),
}))(({ accounts }: { accounts: Account[] }) => ( }))(({ accounts }: { accounts: Account[] }) => (
<Fragment> <Fragment>
{accounts.map(account => { {accounts.map(account => {

9
src/components/modals/ImportAccounts/index.js

@ -4,13 +4,14 @@ import React, { PureComponent } from 'react'
import { compose } from 'redux' import { compose } from 'redux'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { translate } from 'react-i18next' import { translate } from 'react-i18next'
import { createStructuredSelector } from 'reselect'
import type { Currency, Account } from '@ledgerhq/live-common/lib/types' import type { Currency, Account } from '@ledgerhq/live-common/lib/types'
import type { T, Device } from 'types/common' import type { T, Device } from 'types/common'
import { getCurrentDevice } from 'reducers/devices' import { getCurrentDevice } from 'reducers/devices'
import { getAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { addAccount } from 'actions/accounts' import { addAccount } from 'actions/accounts'
import { closeModal } from 'reducers/modals' import { closeModal } from 'reducers/modals'
@ -100,9 +101,9 @@ export type StepProps = {
err: ?Error, err: ?Error,
} }
const mapStateToProps = state => ({ const mapStateToProps = createStructuredSelector({
currentDevice: getCurrentDevice(state), currentDevice: getCurrentDevice,
existingAccounts: getAccounts(state), existingAccounts: accountsSelector,
}) })
const mapDispatchToProps = { const mapDispatchToProps = {

4
src/components/modals/Send/SendModalBody.js

@ -11,7 +11,7 @@ import type { T, Device } from 'types/common'
import type { WalletBridge } from 'bridge/types' import type { WalletBridge } from 'bridge/types'
import { getBridgeForCurrency } from 'bridge' import { getBridgeForCurrency } from 'bridge'
import { getVisibleAccounts } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { updateAccountWithUpdater } from 'actions/accounts' import { updateAccountWithUpdater } from 'actions/accounts'
import Breadcrumb from 'components/Breadcrumb' import Breadcrumb from 'components/Breadcrumb'
@ -53,7 +53,7 @@ type Step = {
} }
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
accounts: getVisibleAccounts, accounts: accountsSelector,
}) })
const mapDispatchToProps = { const mapDispatchToProps = {

28
src/reducers/accounts.js

@ -51,15 +51,7 @@ export function accountsSelector(state: { accounts: AccountsState }): Account[]
return state.accounts return state.accounts
} }
export const archivedAccountsSelector = createSelector(accountsSelector, accounts => export const currenciesSelector = createSelector(accountsSelector, accounts =>
accounts.filter(acc => acc.archived),
)
export const visibleAccountsSelector = createSelector(accountsSelector, accounts =>
accounts.filter(acc => !acc.archived),
)
export const currenciesSelector = createSelector(visibleAccountsSelector, accounts =>
[...new Set(accounts.map(a => a.currency))].sort((a, b) => a.name.localeCompare(b.name)), [...new Set(accounts.map(a => a.currency))].sort((a, b) => a.name.localeCompare(b.name)),
) )
@ -69,24 +61,6 @@ export const accountSelector = createSelector(
(accounts, accountId) => accounts.find(a => a.id === accountId), (accounts, accountId) => accounts.find(a => a.id === accountId),
) )
// TODO remove deprecated selectors
export function getAccounts(state: { accounts: AccountsState }): Account[] {
return state.accounts
}
export function getArchivedAccounts(state: { accounts: AccountsState }): Account[] {
return state.accounts.filter(acc => acc.archived === true)
}
export function getVisibleAccounts(state: { accounts: AccountsState }): Account[] {
return getAccounts(state).filter(account => account.archived !== true)
}
export function getAccountById(state: { accounts: AccountsState }, id: string): ?Account {
return getAccounts(state).find(account => account.id === id)
}
export function decodeAccount(account: AccountRaw): Account { export function decodeAccount(account: AccountRaw): Account {
return accountModel.decode({ return accountModel.decode({
data: account, data: account,

4
src/reducers/bridgeSync.js

@ -3,7 +3,7 @@
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { handleActions } from 'redux-actions' import { handleActions } from 'redux-actions'
import type { State } from 'reducers' import type { State } from 'reducers'
import { getAccounts } from './accounts' import { accountsSelector } from './accounts'
export type AsyncState = { export type AsyncState = {
pending: boolean, pending: boolean,
@ -62,7 +62,7 @@ export const pullMoreStateLocalSelector = (
) => bridgeSync.pullMores[accountId] || nothingState ) => bridgeSync.pullMores[accountId] || nothingState
export const globalSyncStateSelector = createSelector( export const globalSyncStateSelector = createSelector(
getAccounts, accountsSelector,
bridgeSyncSelector, bridgeSyncSelector,
(accounts, bridgeSync) => { (accounts, bridgeSync) => {
const globalSyncState: AsyncState = { const globalSyncState: AsyncState = {

6
yarn.lock

@ -1495,9 +1495,9 @@
npm "^5.7.1" npm "^5.7.1"
prebuild-install "^2.2.2" prebuild-install "^2.2.2"
"@ledgerhq/live-common@2.23.0": "@ledgerhq/live-common@2.24.0":
version "2.23.0" version "2.24.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.23.0.tgz#c039bbb444ceb909fa9c7f17645c39d9c3ce125e" resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.24.0.tgz#0b2f3e5856708b86e0d42e248aab2721d900f42d"
dependencies: dependencies:
axios "^0.18.0" axios "^0.18.0"
invariant "^2.2.2" invariant "^2.2.2"

Loading…
Cancel
Save