From 1d826f7da94e2dd4d6d683cc078aa0cf9fce2b93 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 28 Sep 2022 13:19:26 -0400 Subject: [PATCH] Show curreantly available, reset open to 0 --- functions/src/on-update-contract.ts | 5 +++++ web/components/contract/add-comment-bounty.tsx | 4 +++- web/components/contract/contract-tabs.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/functions/src/on-update-contract.ts b/functions/src/on-update-contract.ts index 181fa534..097ac53a 100644 --- a/functions/src/on-update-contract.ts +++ b/functions/src/on-update-contract.ts @@ -40,6 +40,11 @@ export const onUpdateContract = functions.firestore ) if (toBank.length <= fromBank.length) return + await firestore + .collection('contracts') + .doc(contract.id) + .update({ openCommentBounties: 0 }) + const refunds = toBank.slice(fromBank.length) await Promise.all( refunds.map(async (extraBountyTxn) => { diff --git a/web/components/contract/add-comment-bounty.tsx b/web/components/contract/add-comment-bounty.tsx index 686bca18..4aa36e09 100644 --- a/web/components/contract/add-comment-bounty.tsx +++ b/web/components/contract/add-comment-bounty.tsx @@ -15,6 +15,7 @@ export function AddCommentBountyPanel(props: { contract: Contract }) { const user = useUser() const amount = COMMENT_BOUNTY_AMOUNT + const totalAdded = contract.openCommentBounties ?? 0 const [error, setError] = useState(undefined) const [isSuccess, setIsSuccess] = useState(false) const [isLoading, setIsLoading] = useState(false) @@ -43,7 +44,8 @@ export function AddCommentBountyPanel(props: { contract: Contract }) { <>
Add a {formatMoney(amount)} bounty for good comments that the creator - can award. + can award.{' '} + {totalAdded > 0 && `(${formatMoney(totalAdded)} currently added)`}
diff --git a/web/components/contract/contract-tabs.tsx b/web/components/contract/contract-tabs.tsx index 119ecc0a..a743bd3c 100644 --- a/web/components/contract/contract-tabs.tsx +++ b/web/components/contract/contract-tabs.tsx @@ -50,9 +50,11 @@ export function ContractTabs(props: { { title: `Comments`, tooltip: openCommentBounties - ? `The creator of this market will award bounties of ${formatMoney( + ? `The creator of this market may award ${formatMoney( COMMENT_BOUNTY_AMOUNT - )} to good comments` + )} for good comments. ${formatMoney( + openCommentBounties + )} currently available.` : undefined, content: , inlineTabIcon: ({formatMoney(COMMENT_BOUNTY_AMOUNT)}),