chore(transactions): use lodash.uniqby instead of uniq

This commit is contained in:
George Lima 2019-02-13 15:27:36 -03:00
parent 9886b22a4a
commit 50c76a8145
6 changed files with 20 additions and 5 deletions

View File

@ -188,7 +188,13 @@ export const TransactionDetailsComponent = ({
<InfoRow>
<ColumnComponent width='100%'>
<Label value='TRANSACTION ID' />
<TransactionId onClick={() => openExternal(ZCASH_EXPLORER_BASE_URL + transactionId)}>
<TransactionId
onClick={
from !== '(Shielded)'
? () => openExternal(ZCASH_EXPLORER_BASE_URL + transactionId)
: () => {}
}
>
<Ellipsis value={transactionId} />
</TransactionId>
</ColumnComponent>

View File

@ -3,6 +3,7 @@
import eres from 'eres';
import { connect } from 'react-redux';
import { BigNumber } from 'bignumber.js';
import uuidv4 from 'uuid/v4';
import { TransactionsView } from '../views/transactions';
import {
@ -64,7 +65,7 @@ const mapDispatchToProps = (dispatch: Dispatch): MapDispatchToProps => ({
...transactions,
...listShieldedTransactions({ count, offset: shieldedTransactionsCount }),
].map(transaction => ({
transactionId: transaction.txid ? transaction.txid : null,
transactionId: transaction.txid ? transaction.txid : uuidv4(),
type: transaction.category,
date: new Date(transaction.time * 1000).toISOString(),
address: transaction.address,

View File

@ -1,5 +1,5 @@
// @flow
import uniq from 'lodash.uniq';
import uniqBy from 'lodash.uniqby';
import type { Action } from '../../types/redux';
import type { Transaction } from '../../components/transaction-item';
@ -72,7 +72,7 @@ export default (state: State = initialState, action: Action) => {
return {
...state,
...action.payload,
list: uniq(state.list.concat(action.payload.list)),
list: uniqBy(state.list.concat(action.payload.list), tr => tr.transactionId + tr.type),
isLoading: false,
error: null,
};

View File

@ -0,0 +1,3 @@
declare module 'lodash.uniqby' {
declare module.exports: <T>(arr: T[], (T) => $Values<T>) => T[];
}

View File

@ -108,7 +108,7 @@
"history": "^4.7.2",
"lodash.flow": "^3.5.0",
"lodash.groupby": "^4.6.0",
"lodash.uniq": "^4.5.0",
"lodash.uniqby": "^4.7.0",
"p-queue": "^3.0.0",
"process-exists": "^3.1.0",
"qrcode.react": "^0.8.0",

View File

@ -9238,6 +9238,11 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
lodash.uniqby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302"
integrity sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI=
"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.8.0, lodash@~4.17.10:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"