Skip to content

Commit

Permalink
Include boosts in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Oct 18, 2022
1 parent c58481f commit 9dc58f3
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,49 @@ const Home: React.FC = () => {
return info;
};

const sendBoost = async (
destination: string,
amount: number,
name: string,
boostMsg?: string,
boostSender?: string
) => {
const newSent: any = sent;

try {
const result = await keysend(
destination,
amount,
name,
boostMsg,
boostSender
);
if (result.status === 'SUCCEEDED') {
const msg = `SUCCESS: Boost of ${amount} sats to ${name}`;
console.warn(msg);

newSent[destination] = sent[destination]
? sent[destination].plus(amount)
: new BigNumber(amount);

console.log(`newSent for ${name}: ${newSent[destination]}`);

setSent(newSent);

const total = sentTotal.plus(amount);
setSentTotal(total);
} else {
const msg = `FAILURE: Boost of ${amount} sats to ${name}`;
console.warn(msg);
}
} catch {
const msg = `FAILURE: Boost of ${amount} sats to ${name}`;
console.warn(msg);
}

return;
};

const deleteShow = (showName: string) => {
const newSubscriptions = subscriptions;

Expand Down Expand Up @@ -233,12 +276,9 @@ const Home: React.FC = () => {
setSent(newSent);
setCarry(newCarry);

if (!!sent) {
let total = new BigNumber(0);
Object.keys(sent).map((o: any) => {
total = total.plus(sent[o]);
setSentTotal(total);
});
if (!failure) {
const total = sentTotal.plus(amountToSend);
setSentTotal(total);
}

return;
Expand Down Expand Up @@ -478,7 +518,7 @@ const Home: React.FC = () => {
</p>
<form
onSubmit={(event: any) => {
keysend(
sendBoost(
boostRecipient,
boostAmount,
boostRecipientName,
Expand Down

0 comments on commit 9dc58f3

Please sign in to comment.