Skip to content

Commit

Permalink
Reset filter on route change instead of on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
Gina Contrino committed Jan 17, 2018
1 parent 197d6d3 commit b906def
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/transactions/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { translate } from 'react-i18next';
import { transactionsRequested, transactionsReset } from '../../actions/transactions';
import Transactions from './transactions';
Expand All @@ -21,4 +22,5 @@ const mapDispatchToProps = dispatch => ({
transactionsReset: data => dispatch(transactionsReset(data)),
});

export default connect(mapStateToProps, mapDispatchToProps)(translate()(Transactions));

export default withRouter(connect(mapStateToProps, mapDispatchToProps)(translate()(Transactions)));
10 changes: 6 additions & 4 deletions src/components/transactions/transactionOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class Transactions extends React.Component {
constructor(props) {
super(props);
this.canLoadMore = true;

this.props.history.listen((location) => {
if (location.pathname === '/main/dashboard') {
this.setActiveFilter(txFilters.all);
}
});
}

loadTransactions(filter, offset) {
Expand Down Expand Up @@ -40,10 +46,6 @@ class Transactions extends React.Component {
this.canLoadMore = count === null || count > transactions.length;
}

componentWillUnmount() {
this.setActiveFilter(txFilters.all);
}

setActiveFilter(filter) {
this.props.transactionsReset({ filter });
this.loadTransactions(filter);
Expand Down

0 comments on commit b906def

Please sign in to comment.