From 3a341b033fa2825caca594477e7f610313e4492c Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 29 Jul 2021 22:27:55 +0200 Subject: [PATCH] calculate the total amount of unique creators tipped --- .../walletFiatAccountHistory/view.jsx | 15 ---- .../walletFiatPaymentBalance/view.jsx | 71 +++++-------------- ui/page/wallet/view.jsx | 2 +- 3 files changed, 18 insertions(+), 70 deletions(-) diff --git a/ui/component/walletFiatAccountHistory/view.jsx b/ui/component/walletFiatAccountHistory/view.jsx index 0e06a4a7d..3000722e5 100644 --- a/ui/component/walletFiatAccountHistory/view.jsx +++ b/ui/component/walletFiatAccountHistory/view.jsx @@ -15,21 +15,6 @@ import { Lbryio } from 'lbryinc'; import moment from 'moment'; type Props = { - balance: number, - totalBalance: number, - claimsBalance: number, - supportsBalance: number, - tipsBalance: number, - doOpenModal: (string) => void, - hasSynced: boolean, - doFetchUtxoCounts: () => void, - doUtxoConsolidate: () => void, - fetchingUtxoCounts: boolean, - consolidatingUtxos: boolean, - consolidateIsPending: boolean, - massClaimingTips: boolean, - massClaimIsPending: boolean, - utxoCounts: { [string]: number }, accountDetails: any, transactions: any, }; diff --git a/ui/component/walletFiatPaymentBalance/view.jsx b/ui/component/walletFiatPaymentBalance/view.jsx index 501a1a2b2..95d89c138 100644 --- a/ui/component/walletFiatPaymentBalance/view.jsx +++ b/ui/component/walletFiatPaymentBalance/view.jsx @@ -15,6 +15,7 @@ import { formatNumberWithCommas } from 'util/number'; type Props = { totalTippedAmount: number, accountDetails: any, + transactions: any, }; @@ -23,16 +24,26 @@ const WalletBalance = (props: Props) => { const { accountDetails, totalTippedAmount, + transactions, } = props; const [detailsExpanded, setDetailsExpanded] = React.useState(false); + const [totalCreatorsSupported, setTotalCreatorsSupported] = React.useState(false); + // calculate how many unique users tipped + React.useEffect(() => { + if(transactions){ + let channelNames = [] - console.log('total tipped amount') - console.log(totalTippedAmount) + for(const transaction of transactions){ + channelNames.push(transaction.channel_name) + console.log(transaction.channel_name); + } - // console.log('account details'); - // console.log(accountDetails); + let unique = [...new Set(channelNames)]; + setTotalCreatorsSupported(unique.length); + } + }, [transactions]); return ( <>{1 == 1 && { actions={ <>

- ${totalTippedAmount} Total Paid Out + {transactions && transactions.length} Total Tips

- {'totalCreatorsSupported'} Creators Supported - {/* setDetailsExpanded(!detailsExpanded)}*/} - {/*/>*/} + {totalCreatorsSupported || 0} Creators Supported

- {/* view more section */} - {detailsExpanded && ( -
-
-
- {__('...earned from others')} - ({__('Unlock to spend')}) -
-
- - {Boolean(1) && ( -
- -
- {__('...on initial publishes')} - ({__('Delete or edit past content to spend')}) -
-
- -
- -
- {__('...supporting content')} - ({__('Delete supports to spend')}) -
-
- -
-
-
- )} -
- {/*
diff --git a/ui/page/wallet/view.jsx b/ui/page/wallet/view.jsx index c66a27b89..759ec013d 100644 --- a/ui/page/wallet/view.jsx +++ b/ui/page/wallet/view.jsx @@ -224,7 +224,7 @@ const WalletPage = (props: Props) => { {/* fiat payment history for tips made by user */}
- +