Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show non send transactions in incoming filter - Closes #382 #388

Merged
merged 3 commits into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/components/transactions/transactionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TransactionRow from './transactionRow';
import TransactionsHeader from './transactionsHeader';
import { transactionsRequestInit } from '../../actions/transactions';
import txFilters from './../../constants/transactionFilters';
import txTypes from './../../constants/transactionTypes';
import styles from './transactions.css';

class TransactionsList extends React.Component {
Expand All @@ -27,17 +28,28 @@ class TransactionsList extends React.Component {
}

render() {
const fixIncomingFilter = (transaction) => {
const isTypeNonSend = transaction.type !== txTypes.send;
const isFilterIncoming = this.props.filter
&& this.props.filter.value === txFilters.incoming;
const isAccountInit = transaction.type === txTypes.send
&& transaction.senderId === transaction.recipientId;

return !(isFilterIncoming && (isTypeNonSend || isAccountInit));
};

if (this.props.transactions.length > 0) {
return <div className={`${styles.results} transaction-results`}>
<TransactionsHeader tableStyle={tableStyle}></TransactionsHeader>
{this.props.transactions.map((transaction, i) => (
<TransactionRow address={this.props.address}
key={i}
t={this.props.t}
value={transaction}
nextStep={this.props.nextStep}
/>
))}
{this.props.transactions
.filter(fixIncomingFilter)
.map((transaction, i) => (
<TransactionRow address={this.props.address}
key={i}
t={this.props.t}
value={transaction}
nextStep={this.props.nextStep}
/>))}
{
// the transaction list should be scrollable on a large screen
// otherwise (XS) the whole transaction box will be scrollable
Expand Down
4 changes: 3 additions & 1 deletion test/integration/accountTransactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import accountMiddleware from '../../src/store/middlewares/account';
import transactionsMiddleware from '../../src/store/middlewares/transactions';
import { activePeerSet } from '../../src/actions/peers';
import networks from './../../src/constants/networks';
import txTypes from './../../src/constants/transactionTypes';
import getNetwork from './../../src/utils/getNetwork';
import { accountLoggedIn } from '../../src/actions/account';
import AccountTransactions from './../../src/components/accountTransactions';
Expand All @@ -31,7 +32,7 @@ describe('@integration: Account Transactions', () => {
requestToActivePeerStub = stub(peers, 'requestToActivePeer');
accountAPIStub = stub(accountAPI, 'getAccount');

const transactionExample = { senderId: '456L', receiverId: '456L' };
const transactionExample = { senderId: '456L', receiverId: '456L', type: txTypes.send };

// specific address
let transactions = new Array(20);
Expand All @@ -42,6 +43,7 @@ describe('@integration: Account Transactions', () => {
// incoming transaction result
transactions = new Array(15);
transactions.fill(transactionExample);
transactions.push({ senderId: 'sample_address', receiverId: 'some_address', type: txTypes.vote });
requestToActivePeerStub.withArgs(match.any, 'transactions', match({ senderId: undefined }))
.returnsPromise().resolves({ transactions, count: 1000 });

Expand Down
4 changes: 3 additions & 1 deletion test/integration/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import transactionsMiddleware from '../../src/store/middlewares/transactions';
import { accountLoggedIn } from '../../src/actions/account';
import { activePeerSet } from '../../src/actions/peers';
import networks from './../../src/constants/networks';
import txTypes from './../../src/constants/transactionTypes';
import getNetwork from './../../src/utils/getNetwork';
import Wallet from '../../src/components/transactionDashboard';
import accounts from '../constants/accounts';
Expand All @@ -39,7 +40,7 @@ describe('@integration: Wallet', () => {
localStorageStub = stub(localStorage, 'getItem');
localStorageStub.withArgs('accounts').returns(JSON.stringify([{}, {}]));

const transactionExample = { senderId: 'sample_address', receiverId: 'some_address' };
const transactionExample = { senderId: 'sample_address', receiverId: 'some_address', type: txTypes.send };

requestToActivePeerStub.withArgs(match.any, 'transactions', match({
recipientId: '537318935439898807L',
Expand All @@ -56,6 +57,7 @@ describe('@integration: Wallet', () => {
// incoming transaction result
transactions = new Array(15);
transactions.fill(transactionExample);
transactions.push({ senderId: 'sample_address', receiverId: 'some_address', type: txTypes.vote });
requestToActivePeerStub.withArgs(match.any, 'transactions', match({ senderId: undefined }))
.returnsPromise().resolves({ transactions, count: 1000 });

Expand Down