diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe6ddd06..f1baee4e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Focus on search bar with {cmd,ctrl} + "l" ([#2003](https://github.com/lbryio/lbry-desktop/pull/2003)) * Add support for clickable channel names on explore page headings ([#2023](https://github.com/lbryio/lbry-desktop/pull/2023)) * Content loading placeholder styles on FileCard/FileTile ([#2022](https://github.com/lbryio/lbry-desktop/pull/2022)) + * Adds Persistence to Transaction List Filter Selection ([#2048](https://github.com/lbryio/lbry-desktop/pull/2048)) ### Changed * Make tooltip smarter ([#1979](https://github.com/lbryio/lbry-desktop/pull/1979)) diff --git a/package.json b/package.json index 0fe9622c2..4d64565d3 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "formik": "^0.10.4", "hast-util-sanitize": "^1.1.2", "keytar": "^4.2.1", - "lbry-redux": "lbryio/lbry-redux#4ee6c376e5f2c3e3e96d199a56970e2621a84af1", + "lbry-redux": "lbryio/lbry-redux#67cae46983d9fea90dd1e4c5bd121dd5077a3f0e", "lbryinc": "lbryio/lbryinc#de7ff055605b02a24821f0f9bab1d206eb7f235d", "localforage": "^1.7.1", "mammoth": "^1.4.6", diff --git a/src/renderer/component/transactionList/index.js b/src/renderer/component/transactionList/index.js index fde907969..09435e9fd 100644 --- a/src/renderer/component/transactionList/index.js +++ b/src/renderer/component/transactionList/index.js @@ -1,17 +1,24 @@ import { connect } from 'react-redux'; import { selectClaimedRewardsByTransactionId } from 'lbryinc'; import { doNavigate } from 'redux/actions/navigation'; -import { selectAllMyClaimsByOutpoint, doNotify } from 'lbry-redux'; +import { + selectAllMyClaimsByOutpoint, + doNotify, + selectTransactionListFilter, + doSetTransactionListFilter, +} from 'lbry-redux'; import TransactionList from './view'; const select = state => ({ rewards: selectClaimedRewardsByTransactionId(state), myClaims: selectAllMyClaimsByOutpoint(state), + filterSetting: selectTransactionListFilter(state), }); const perform = dispatch => ({ navigate: (path, params) => dispatch(doNavigate(path, params)), openModal: (modal, props) => dispatch(doNotify(modal, props)), + setTransactionFilter: filterSetting => dispatch(doSetTransactionListFilter(filterSetting)), }); export default connect( diff --git a/src/renderer/component/transactionList/view.jsx b/src/renderer/component/transactionList/view.jsx index c498a19b5..4aaf9ae27 100644 --- a/src/renderer/component/transactionList/view.jsx +++ b/src/renderer/component/transactionList/view.jsx @@ -25,20 +25,14 @@ type Props = { rewards: {}, openModal: ({ id: string }, { nout: number, txid: string }) => void, myClaims: any, + filterSetting: string, + setTransactionFilter: string => void, }; -type State = { - filter: string, -}; - -class TransactionList extends React.PureComponent { +class TransactionList extends React.PureComponent { constructor(props: Props) { super(props); - this.state = { - filter: 'all', - }; - (this: any).handleFilterChanged = this.handleFilterChanged.bind(this); (this: any).filterTransaction = this.filterTransaction.bind(this); (this: any).revokeClaim = this.revokeClaim.bind(this); @@ -50,15 +44,13 @@ class TransactionList extends React.PureComponent { } handleFilterChanged(event: SyntheticInputEvent<*>) { - this.setState({ - filter: event.target.value, - }); + this.props.setTransactionFilter(event.target.value); } filterTransaction(transaction: Transaction) { - const { filter } = this.state; - - return filter === 'all' || filter === transaction.type; + return ( + this.props.filterSetting === TRANSACTIONS.ALL || this.props.filterSetting === transaction.type + ); } isRevokeable(txid: string, nout: number) { @@ -73,9 +65,12 @@ class TransactionList extends React.PureComponent { } render() { - const { emptyMessage, rewards, transactions, slim } = this.props; - const { filter } = this.state; + const { emptyMessage, rewards, transactions, slim, filterSetting } = this.props; const transactionList = transactions.filter(this.filterTransaction); + // Flow offers little support for Object.values() typing. + // https://github.com/facebook/flow/issues/2221 + // $FlowFixMe + const transactionTypes: Array = Object.values(TRANSACTIONS); return ( @@ -98,7 +93,7 @@ class TransactionList extends React.PureComponent {
{ /> } > - - - - - - - - - + {transactionTypes.map(tt => ( + + ))}
)} diff --git a/yarn.lock b/yarn.lock index 5f1f4193e..60f05346b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5666,9 +5666,9 @@ lbry-redux@lbryio/lbry-redux: proxy-polyfill "0.1.6" reselect "^3.0.0" -lbry-redux@lbryio/lbry-redux#4ee6c376e5f2c3e3e96d199a56970e2621a84af1: +lbry-redux@lbryio/lbry-redux#67cae46983d9fea90dd1e4c5bd121dd5077a3f0e: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/4ee6c376e5f2c3e3e96d199a56970e2621a84af1" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/67cae46983d9fea90dd1e4c5bd121dd5077a3f0e" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0"