import React, { Component } from 'react' import PropTypes from 'prop-types' import Wallet from 'components/Wallet' import LoadingBolt from 'components/LoadingBolt' import Invoice from './components/Invoice' import Payment from './components/Payment' import Transaction from './components/Transaction' import Modal from './components/Modal' import styles from './Activity.scss' class Activity extends Component { constructor(props, context) { super(props, context) this.renderActivity = this.renderActivity.bind(this) } componentWillMount() { const { fetchPayments, fetchInvoices, fetchTransactions, fetchBalance } = this.props fetchBalance() fetchPayments() fetchInvoices() fetchTransactions() } renderActivity(activity) { const { ticker, currentTicker, showActivityModal } = this.props if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) { // activity is an on-chain tx return } else if (Object.prototype.hasOwnProperty.call(activity, 'payment_request')) { // activity is an LN invoice return } // activity is an LN payment return } render() { const { ticker, invoice: { invoiceLoading }, address: { address }, balance, info, payment: { paymentLoading }, currentTicker, activity: { modal, filters, filter, filterPulldown }, hideActivityModal, changeFilter, currentActivity, newAddress, openPayForm, openRequestForm } = this.props if (invoiceLoading || paymentLoading) { return } if (balance.balanceLoading) { return } if (!balance.channelBalance || !balance.walletBalance) { return } return (
    { filters.map(f => (
  • changeFilter(f)}> {f.name}
  • )) }
    { currentActivity.map((activity, index) => (
  • {this.renderActivity(activity)}
  • )) }
) } } Activity.propTypes = { fetchPayments: PropTypes.func.isRequired, fetchInvoices: PropTypes.func.isRequired, fetchTransactions: PropTypes.func.isRequired, fetchBalance: PropTypes.func.isRequired, ticker: PropTypes.object.isRequired, invoice: PropTypes.object.isRequired, payment: PropTypes.object.isRequired, currentTicker: PropTypes.object.isRequired, showActivityModal: PropTypes.func.isRequired, hideActivityModal: PropTypes.func.isRequired, changeFilter: PropTypes.func.isRequired, newAddress: PropTypes.func.isRequired, openPayForm: PropTypes.func.isRequired, openRequestForm: PropTypes.func.isRequired, activity: PropTypes.object.isRequired, currentActivity: PropTypes.array.isRequired, address: PropTypes.object.isRequired, balance: PropTypes.object.isRequired, info: PropTypes.object.isRequired } export default Activity