call claim_list_mine on page entry and add refresh button

This commit is contained in:
Sean Yesmunt 2018-11-07 14:35:47 -05:00
parent 3de1298d25
commit 2c9c174ed8
5 changed files with 92 additions and 60 deletions

View file

@ -82,7 +82,7 @@ class TransactionList extends React.PureComponent<Props> {
)} )}
{!slim && {!slim &&
!!transactionList.length && ( !!transactionList.length && (
<div className="card__actions"> <div className="card__actions card__actions--between">
<FileExporter <FileExporter
data={transactionList} data={transactionList}
label={__('Export')} label={__('Export')}
@ -90,10 +90,7 @@ class TransactionList extends React.PureComponent<Props> {
filters={['nout']} filters={['nout']}
defaultPath={__('lbry-transactions-history')} defaultPath={__('lbry-transactions-history')}
/> />
</div>
)}
{!slim && ( {!slim && (
<div className="card__actions-top-corner">
<FormField <FormField
type="select" type="select"
value={filterSetting || TRANSACTIONS.ALL} value={filterSetting || TRANSACTIONS.ALL}
@ -115,6 +112,7 @@ class TransactionList extends React.PureComponent<Props> {
</option> </option>
))} ))}
</FormField> </FormField>
)}
</div> </div>
)} )}
{!!transactionList.length && ( {!!transactionList.length && (

View file

@ -4,6 +4,7 @@ import {
selectRecentTransactions, selectRecentTransactions,
selectHasTransactions, selectHasTransactions,
selectIsFetchingTransactions, selectIsFetchingTransactions,
doFetchClaimListMine,
} from 'lbry-redux'; } from 'lbry-redux';
import TransactionListRecent from './view'; import TransactionListRecent from './view';
@ -15,6 +16,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
fetchTransactions: () => dispatch(doFetchTransactions()), fetchTransactions: () => dispatch(doFetchTransactions()),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
}); });
export default connect( export default connect(

View file

@ -1,5 +1,5 @@
// @flow // @flow
import React from 'react'; import React, { Fragment } from 'react';
import BusyIndicator from 'component/common/busy-indicator'; import BusyIndicator from 'component/common/busy-indicator';
import Button from 'component/button'; import Button from 'component/button';
import TransactionList from 'component/transactionList'; import TransactionList from 'component/transactionList';
@ -11,36 +11,49 @@ type Props = {
fetchingTransactions: boolean, fetchingTransactions: boolean,
hasTransactions: boolean, hasTransactions: boolean,
transactions: Array<Transaction>, transactions: Array<Transaction>,
fetchMyClaims: () => void,
}; };
class TransactionListRecent extends React.PureComponent<Props> { class TransactionListRecent extends React.PureComponent<Props> {
componentDidMount() { componentDidMount() {
this.props.fetchTransactions(); const { fetchMyClaims, fetchTransactions } = this.props;
fetchMyClaims();
fetchTransactions();
} }
render() { render() {
const { fetchingTransactions, hasTransactions, transactions } = this.props; const { fetchingTransactions, hasTransactions, transactions, fetchTransactions } = this.props;
return ( return (
<section className="card card--section"> <section className="card card--section">
<div className="card__title">{__('Recent Transactions')}</div> <div className="card__title card--space-between">
{__('Recent Transactions')}
<div className="card__actions-top-corner">
<Button
button="inverse"
label={__('Refresh')}
onClick={fetchTransactions}
disabled={fetchingTransactions}
/>
</div>
</div>
<div className="card__subtitle"> <div className="card__subtitle">
{__('To view all of your transactions, navigate to the')}{' '} {__('To view all of your transactions, navigate to the')}{' '}
<Button button="link" navigate="/history" label={__('transactions page')} />. <Button button="link" navigate="/history" label={__('transactions page')} />.
</div> </div>
{fetchingTransactions && ( {fetchingTransactions &&
!hasTransactions && (
<div className="card__content"> <div className="card__content">
<BusyIndicator message={__('Loading transactions')} /> <BusyIndicator message={__('Loading transactions')} />
</div> </div>
)} )}
{!fetchingTransactions && ( {hasTransactions && (
<Fragment>
<TransactionList <TransactionList
slim slim
transactions={transactions} transactions={transactions}
emptyMessage={__("Looks like you don't have any recent transactions.")} emptyMessage={__("Looks like you don't have any recent transactions.")}
/> />
)}
{hasTransactions && (
<div className="card__actions"> <div className="card__actions">
<Button <Button
button="primary" button="primary"
@ -49,6 +62,7 @@ class TransactionListRecent extends React.PureComponent<Props> {
icon={icons.CLOCK} icon={icons.CLOCK}
/> />
</div> </div>
</Fragment>
)} )}
</section> </section>
); );

View file

@ -3,6 +3,7 @@ import {
doFetchTransactions, doFetchTransactions,
selectTransactionItems, selectTransactionItems,
selectIsFetchingTransactions, selectIsFetchingTransactions,
doFetchClaimListMine,
} from 'lbry-redux'; } from 'lbry-redux';
import TransactionHistoryPage from './view'; import TransactionHistoryPage from './view';
@ -13,6 +14,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
fetchTransactions: () => dispatch(doFetchTransactions()), fetchTransactions: () => dispatch(doFetchTransactions()),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
}); });
export default connect( export default connect(

View file

@ -1,25 +1,41 @@
// @flow
import React from 'react'; import React from 'react';
import BusyIndicator from 'component/common/busy-indicator'; import BusyIndicator from 'component/common/busy-indicator';
import TransactionList from 'component/transactionList'; import TransactionList from 'component/transactionList';
import Page from 'component/page'; import Page from 'component/page';
import Button from 'component/button';
class TransactionHistoryPage extends React.PureComponent { type Props = {
componentWillMount() { fetchMyClaims: () => void,
this.props.fetchTransactions(); fetchTransactions: () => void,
fetchingTransactions: boolean,
transactions: Array<{}>,
};
class TransactionHistoryPage extends React.PureComponent<Props> {
componentDidMount() {
const { fetchMyClaims, fetchTransactions } = this.props;
fetchMyClaims();
fetchTransactions();
} }
render() { render() {
const { fetchingTransactions, transactions } = this.props; const { fetchingTransactions, transactions, fetchTransactions } = this.props;
return ( return (
<Page> <Page>
<section className="card card--section"> <section className="card card--section">
<div <div className="card__title card--space-between">
className={`card__title ${ {__('Transaction History')}
fetchingTransactions && transactions.length ? 'reloading' : '' <div className="card__actions-top-corner">
}`} <Button
> button="inverse"
<h3>{__('Transaction History')}</h3> label={__('Refresh')}
onClick={fetchTransactions}
disabled={fetchingTransactions}
/>
</div>
</div> </div>
{fetchingTransactions && !transactions.length ? ( {fetchingTransactions && !transactions.length ? (
<div className="card__content"> <div className="card__content">