From fced164b8f9f19fe11d767610df97e3cb95a4dca Mon Sep 17 00:00:00 2001 From: Maxwell Lasky Date: Wed, 27 Feb 2019 10:27:13 -0700 Subject: [PATCH 1/2] adds polling to activity tab and changes language around transaction 'completion' --- .../Send/SendPanel/SendSuccess/index.jsx | 2 +- .../TransactionHistoryPanel.jsx | 26 +++++++++++++++++++ .../TransactionHistoryPanel/index.js | 11 ++++++++ app/containers/Dashboard/Dashboard.jsx | 5 +--- app/modules/transactions.js | 2 +- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/components/Send/SendPanel/SendSuccess/index.jsx b/app/components/Send/SendPanel/SendSuccess/index.jsx index 88a2198e7..641166467 100644 --- a/app/components/Send/SendPanel/SendSuccess/index.jsx +++ b/app/components/Send/SendPanel/SendSuccess/index.jsx @@ -39,7 +39,7 @@ export default class SendSuccess extends React.Component {

- {numberOfItems} {pluralize('Transfer', numberOfItems)} completed + {numberOfItems} {pluralize('Transfer', numberOfItems)} pending

{this.txFormattedDate} diff --git a/app/components/TransactionHistory/TransactionHistoryPanel/TransactionHistoryPanel.jsx b/app/components/TransactionHistory/TransactionHistoryPanel/TransactionHistoryPanel.jsx index 4d3ca4f6f..f9e594054 100644 --- a/app/components/TransactionHistory/TransactionHistoryPanel/TransactionHistoryPanel.jsx +++ b/app/components/TransactionHistory/TransactionHistoryPanel/TransactionHistoryPanel.jsx @@ -13,16 +13,29 @@ type Props = { transactions: Array, handleFetchAdditionalTxData: () => void, handleGetPendingTransactionInfo: () => void, + handleRefreshTxData: () => void, pendingTransactions: Array, address: string, } +const REFRESH_INTERVAL_MS = 30000 + export default class TransactionHistory extends React.Component { + transactionDataInterval: IntervalID + static defaultProps = { transactions: [], pendingTransactions: [], } + componentDidMount() { + this.addPolling() + } + + componentWillUnmount() { + this.removePolling() + } + render() { const { className, transactions } = this.props const filteredPendingTransactions = this.pruneConfirmedTransactionsFromPending() @@ -41,6 +54,19 @@ export default class TransactionHistory extends React.Component { ) } + addPolling = () => { + this.transactionDataInterval = setInterval(async () => { + await this.props.handleGetPendingTransactionInfo() + this.props.handleRefreshTxData() + }, REFRESH_INTERVAL_MS) + } + + removePolling = () => { + if (this.transactionDataInterval) { + clearInterval(this.transactionDataInterval) + } + } + pruneConfirmedTransactionsFromPending() { const { transactions, pendingTransactions } = this.props const confirmed = transactions.map(tx => tx.txid) diff --git a/app/components/TransactionHistory/TransactionHistoryPanel/index.js b/app/components/TransactionHistory/TransactionHistoryPanel/index.js index fdeeacc98..37b246567 100644 --- a/app/components/TransactionHistory/TransactionHistoryPanel/index.js +++ b/app/components/TransactionHistory/TransactionHistoryPanel/index.js @@ -9,6 +9,7 @@ import withProgressPanel from '../../../hocs/withProgressPanel' import withAuthData from '../../../hocs/withAuthData' import withNetworkData from '../../../hocs/withNetworkData' import withLoadingProp from '../../../hocs/withLoadingProp' +import withSuccessNotification from '../../../hocs/withSuccessNotification' const mapTransactionsDataToProps = transactions => ({ transactions, @@ -21,6 +22,12 @@ const mapAccountActionsToProps = (actions, { net, address }) => ({ address, shouldIncrementPagination: true, }), + handleRefreshTxData: () => + actions.call({ + net, + address, + shouldIncrementPagination: false, + }), }) const mapPendingTransactionActionsToProps = (actions, { net, address }) => ({ @@ -47,4 +54,8 @@ export default compose( withData(getPendingTransactionInfo, mapPendingTransactionInfoToProps), withLoadingProp(transactionHistoryActions), withData(transactionHistoryActions, mapTransactionsDataToProps), + withSuccessNotification( + transactionHistoryActions, + 'Received latest transaction information.', + ), )(TransactionHistoryPanel) diff --git a/app/containers/Dashboard/Dashboard.jsx b/app/containers/Dashboard/Dashboard.jsx index 8a24202ba..917c9efb0 100644 --- a/app/containers/Dashboard/Dashboard.jsx +++ b/app/containers/Dashboard/Dashboard.jsx @@ -25,7 +25,7 @@ type Props = { const REFRESH_INTERVAL_MS = 30000 export default class Dashboard extends Component { - walletDataInterval: ?number + walletDataInterval: ?IntervalID componentDidMount() { this.addPolling() @@ -80,7 +80,6 @@ export default class Dashboard extends Component { } addPolling = () => { - // $FlowFixMe this.walletDataInterval = setInterval( this.props.loadWalletData, REFRESH_INTERVAL_MS, @@ -88,9 +87,7 @@ export default class Dashboard extends Component { } removePolling = () => { - // $FlowFixMe if (this.walletDataInterval) { - // $FlowFixMe clearInterval(this.walletDataInterval) } } diff --git a/app/modules/transactions.js b/app/modules/transactions.js index 5b464563e..a65f98b48 100644 --- a/app/modules/transactions.js +++ b/app/modules/transactions.js @@ -190,7 +190,7 @@ export const sendTransaction = ({ dispatch( showSuccessNotification({ message: - 'Transaction complete! Your balance will automatically update when the blockchain has processed it.', + 'Transaction pending! Your balance will automatically update when the blockchain has processed it.', }), ) return resolve(response) From 7ee21c8f13376b74299e8307782f64915ba243d8 Mon Sep 17 00:00:00 2001 From: Maxwell Lasky Date: Wed, 27 Feb 2019 10:29:27 -0700 Subject: [PATCH 2/2] updates snapshots --- .../__snapshots__/TransactionHistoryPanel.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/components/__snapshots__/TransactionHistoryPanel.test.js.snap b/__tests__/components/__snapshots__/TransactionHistoryPanel.test.js.snap index ef16e2d99..b869f301f 100644 --- a/__tests__/components/__snapshots__/TransactionHistoryPanel.test.js.snap +++ b/__tests__/components/__snapshots__/TransactionHistoryPanel.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`TransactionHistoryPanel renders without crashing 1`] = ` -