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-node-hid": "^4.12.0",
"@ledgerhq/ledger-core": "1.4.1",
"@ledgerhq/live-common": "2.23.0",
"@ledgerhq/live-common": "2.24.0",
"axios": "^0.18.0",
"babel-runtime": "^6.26.0",
"bcryptjs": "^2.4.3",

2
src/bridge/EthereumJSBridge.js

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

1
src/bridge/RippleJSBridge.js

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

1
src/bridge/makeMockBridge.js

@ -91,7 +91,6 @@ function makeMockBridge(opts?: Opts): WalletBridge<*> {
currency,
})
account.unit = currency.units[0]
account.archived = false
if (!unsubscribed) next(account)
}
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 { getAccountById } from 'reducers/accounts'
import { accountSelector } from 'reducers/accounts'
import { counterValueCurrencySelector, localeSelector } from 'reducers/settings'
import { openModal } from 'reducers/modals'
@ -50,7 +50,7 @@ const ButtonSettings = styled(Button).attrs({
`
const mapStateToProps = (state, props) => ({
account: getAccountById(state, props.match.params.id),
account: accountSelector(state, { accountId: props.match.params.id }),
counterValue: counterValueCurrencySelector(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 { push } from 'react-router-redux'
import chunk from 'lodash/chunk'
import { createStructuredSelector } from 'reselect'
import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common'
import { colors } from 'styles/theme'
import { getVisibleAccounts } from 'reducers/accounts'
import { accountsSelector } from 'reducers/accounts'
import { counterValueCurrencySelector, localeSelector } from 'reducers/settings'
import { updateOrderAccounts } from 'actions/accounts'
@ -30,10 +31,10 @@ import AccountCard from './AccountCard'
import AccountsOrder from './AccountsOrder'
import EmptyState from './EmptyState'
const mapStateToProps = state => ({
accounts: getVisibleAccounts(state),
counterValue: counterValueCurrencySelector(state),
locale: localeSelector(state),
const mapStateToProps = createStructuredSelector({
accounts: accountsSelector,
counterValue: counterValueCurrencySelector,
locale: localeSelector,
})
const mapDispatchToProps = {

4
src/components/QRCodeExporter.js

@ -4,7 +4,7 @@ import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import type { State } from 'reducers'
import { getVisibleAccounts } from 'reducers/accounts'
import { accountsSelector } from 'reducers/accounts'
import QRCode from './base/QRCode'
// 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 data = [
['meta', chunksFormatVersion, 'desktop', desktopVersion],
...getVisibleAccounts(state).map(account => [
...accountsSelector(state).map(account => [
'account',
account.id,
account.name,

7
src/components/SelectAccount/index.js

@ -4,20 +4,21 @@ import React from 'react'
import { connect } from 'react-redux'
import { translate } from 'react-i18next'
import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react'
import { createStructuredSelector } from 'reselect'
import type { Account } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common'
import type { Option } from 'components/base/Select'
import { getVisibleAccounts } from 'reducers/accounts'
import { accountsSelector } from 'reducers/accounts'
import Select from 'components/base/Select'
import FormattedVal from 'components/base/FormattedVal'
import Box from 'components/base/Box'
import Text from 'components/base/Text'
const mapStateToProps = state => ({
accounts: getVisibleAccounts(state),
const mapStateToProps = createStructuredSelector({
accounts: accountsSelector,
})
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 { openModal } from 'reducers/modals'
import { getVisibleAccounts } from 'reducers/accounts'
import { accountsSelector } from 'reducers/accounts'
import { getUpdateStatus } from 'reducers/update'
import type { UpdateStatus } from 'reducers/update'
@ -62,7 +62,7 @@ type Props = {
}
const mapStateToProps = state => ({
accounts: getVisibleAccounts(state),
accounts: accountsSelector(state),
updateStatus: getUpdateStatus(state),
})
@ -125,7 +125,7 @@ class SideBar extends PureComponent<Props> {
}
const AccountsList = connect(state => ({
accounts: getVisibleAccounts(state),
accounts: accountsSelector(state),
}))(({ accounts }: { accounts: Account[] }) => (
<Fragment>
{accounts.map(account => {

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

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

28
src/reducers/accounts.js

@ -51,15 +51,7 @@ export function accountsSelector(state: { accounts: AccountsState }): Account[]
return state.accounts
}
export const archivedAccountsSelector = 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 =>
export const currenciesSelector = createSelector(accountsSelector, accounts =>
[...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),
)
// 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 {
return accountModel.decode({
data: account,

4
src/reducers/bridgeSync.js

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

6
yarn.lock

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

Loading…
Cancel
Save