From 8870f0d356cfd9c2192028c57e8225b06fca5de3 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 20 Sep 2022 15:58:47 -0700 Subject: [PATCH] Don't always require tips to render comments (#898) --- web/components/contract/contract-leaderboard.tsx | 5 +---- web/components/contract/contract-tabs.tsx | 6 +++--- web/components/feed/feed-answer-comment-group.tsx | 2 +- web/components/feed/feed-comments.tsx | 6 +++--- web/pages/[username]/[contractSlug].tsx | 5 ----- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/web/components/contract/contract-leaderboard.tsx b/web/components/contract/contract-leaderboard.tsx index a863f1bf..4d25ffa4 100644 --- a/web/components/contract/contract-leaderboard.tsx +++ b/web/components/contract/contract-leaderboard.tsx @@ -5,7 +5,6 @@ import { Contract } from 'common/contract' import { formatMoney } from 'common/util/format' import { groupBy, mapValues, sumBy, sortBy, keyBy } from 'lodash' import { useState, useMemo, useEffect } from 'react' -import { CommentTipMap } from 'web/hooks/use-tip-txns' import { listUsers, User } from 'web/lib/firebase/users' import { FeedBet } from '../feed/feed-bets' import { FeedComment } from '../feed/feed-comments' @@ -66,9 +65,8 @@ export function ContractTopTrades(props: { contract: Contract bets: Bet[] comments: ContractComment[] - tips: CommentTipMap }) { - const { contract, bets, comments, tips } = props + const { contract, bets, comments } = props const commentsById = keyBy(comments, 'id') const betsById = keyBy(bets, 'id') @@ -105,7 +103,6 @@ export function ContractTopTrades(props: { diff --git a/web/components/contract/contract-tabs.tsx b/web/components/contract/contract-tabs.tsx index a9953bbe..b1364fbf 100644 --- a/web/components/contract/contract-tabs.tsx +++ b/web/components/contract/contract-tabs.tsx @@ -11,9 +11,9 @@ import { ContractBetsTable, BetsSummary } from '../bets-list' import { Spacer } from '../layout/spacer' import { Tabs } from '../layout/tabs' import { Col } from '../layout/col' -import { CommentTipMap } from 'web/hooks/use-tip-txns' import { useComments } from 'web/hooks/use-comments' import { useLiquidity } from 'web/hooks/use-liquidity' +import { useTipTxns } from 'web/hooks/use-tip-txns' import { capitalize } from 'lodash' import { DEV_HOUSE_LIQUIDITY_PROVIDER_ID, @@ -26,12 +26,12 @@ export function ContractTabs(props: { user: User | null | undefined bets: Bet[] comments: ContractComment[] - tips: CommentTipMap }) { - const { contract, user, bets, tips } = props + const { contract, user, bets } = props const { outcomeType } = contract const isMobile = useIsMobile() + const tips = useTipTxns({ contractId: contract.id }) const lps = useLiquidity(contract.id) const userBets = diff --git a/web/components/feed/feed-answer-comment-group.tsx b/web/components/feed/feed-answer-comment-group.tsx index 84f1e8c5..27f0f731 100644 --- a/web/components/feed/feed-answer-comment-group.tsx +++ b/web/components/feed/feed-answer-comment-group.tsx @@ -106,7 +106,7 @@ export function FeedAnswerCommentGroup(props: { indent={true} contract={contract} comment={comment} - tips={tips[comment.id]} + tips={tips[comment.id] ?? {}} onReplyClick={scrollAndOpenReplyInput} /> ))} diff --git a/web/components/feed/feed-comments.tsx b/web/components/feed/feed-comments.tsx index 027b377f..acb48ec1 100644 --- a/web/components/feed/feed-comments.tsx +++ b/web/components/feed/feed-comments.tsx @@ -47,7 +47,7 @@ export function FeedCommentThread(props: { indent={commentIdx != 0} contract={contract} comment={comment} - tips={tips[comment.id]} + tips={tips[comment.id] ?? {}} onReplyClick={scrollAndOpenReplyInput} /> ))} @@ -74,7 +74,7 @@ export function FeedCommentThread(props: { export function FeedComment(props: { contract: Contract comment: ContractComment - tips: CommentTips + tips?: CommentTips indent?: boolean onReplyClick?: (comment: ContractComment) => void }) { @@ -170,7 +170,7 @@ export function FeedComment(props: { smallImage /> - + {tips && } {onReplyClick && (