From fac87f8e0c82877a68bf4bcd6a933af7afa630e0 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sat, 1 Oct 2022 16:10:17 -0500 Subject: [PATCH] tips: display total --- web/components/tipper.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/components/tipper.tsx b/web/components/tipper.tsx index 1f6b6e53..a8c7cb4e 100644 --- a/web/components/tipper.tsx +++ b/web/components/tipper.tsx @@ -1,4 +1,4 @@ -import { debounce } from 'lodash' +import { debounce, sum } from 'lodash' import { useEffect, useRef, useState } from 'react' import { Comment } from 'common/comment' @@ -29,6 +29,8 @@ export function Tipper(prop: { comment: Comment; tips: CommentTips }) { } }, [tips, myId]) + const total = sum(Object.values(tips)) - savedTip + localTip + // declare debounced function only on first render const [saveTip] = useState(() => debounce(async (user: User, comment: Comment, change: number) => { @@ -82,7 +84,7 @@ export function Tipper(prop: { comment: Comment; tips: CommentTips }) { addTip(+LIKE_TIP_AMOUNT)} userTipped={localTip > 0} disabled={!canUp}