Merge pull request #2048 from jessopb/txListFilterPersist
persists transaction filter: RE #1154
This commit is contained in:
commit
0d0cc5bb00
5 changed files with 30 additions and 47 deletions
|
@ -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))
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<Props, State> {
|
||||
class TransactionList extends React.PureComponent<Props> {
|
||||
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<Props, State> {
|
|||
}
|
||||
|
||||
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<Props, State> {
|
|||
}
|
||||
|
||||
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<string> = Object.values(TRANSACTIONS);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -98,7 +93,7 @@ class TransactionList extends React.PureComponent<Props, State> {
|
|||
<div className="card__actions-top-corner">
|
||||
<FormField
|
||||
type="select"
|
||||
value={filter}
|
||||
value={filterSetting || TRANSACTIONS.ALL}
|
||||
onChange={this.handleFilterChanged}
|
||||
affixClass="form-field--align-center"
|
||||
prefix={__('Show')}
|
||||
|
@ -111,31 +106,11 @@ class TransactionList extends React.PureComponent<Props, State> {
|
|||
/>
|
||||
}
|
||||
>
|
||||
<option value="all">{__('All')}</option>
|
||||
<option value={TRANSACTIONS.SPEND}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.SPEND)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.RECEIVE}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.RECEIVE)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.PUBLISH}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.PUBLISH)}es`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.CHANNEL}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.CHANNEL)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.TIP}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.TIP)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.SUPPORT}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.SUPPORT)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.UPDATE}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.UPDATE)}s`)}
|
||||
</option>
|
||||
<option value={TRANSACTIONS.ABANDON}>
|
||||
{__(`${this.capitalize(TRANSACTIONS.ABANDON)}s`)}
|
||||
{transactionTypes.map(tt => (
|
||||
<option key={tt} value={tt}>
|
||||
{__(`${this.capitalize(tt)}`)}
|
||||
</option>
|
||||
))}
|
||||
</FormField>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue