From 1683a3842bc30e6bfc52e482ea539fedac53a401 Mon Sep 17 00:00:00 2001 From: jahooma Date: Thu, 13 Jan 2022 15:16:47 -0600 Subject: [PATCH] Link to user from feed mentions. Show name instead of username in card. --- web/components/bets-list.tsx | 7 ++++--- web/components/contract-card.tsx | 21 ++++++++++++-------- web/components/contract-feed.tsx | 33 ++++++++++++++++++++++++-------- web/components/user-page.tsx | 12 +++++++++--- 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 8a9f816c..1ca7b38a 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -151,9 +151,10 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { -
- -
+ {resolution && ( <>
diff --git a/web/components/contract-card.tsx b/web/components/contract-card.tsx index 9fc08526..6b5ed829 100644 --- a/web/components/contract-card.tsx +++ b/web/components/contract-card.tsx @@ -102,15 +102,17 @@ export function AbbrContractDetails(props: { showHotVolume?: boolean }) { const { contract, showHotVolume } = props - const { volume24Hours } = contract + const { volume24Hours, creatorName, creatorUsername } = contract const { truePool } = contractMetrics(contract) return ( -
- -
+
{showHotVolume ? (
@@ -127,7 +129,8 @@ export function AbbrContractDetails(props: { export function ContractDetails(props: { contract: Contract }) { const { contract } = props - const { question, description, closeTime } = contract + const { question, description, closeTime, creatorName, creatorUsername } = + contract const { truePool, createdDate, resolvedDate } = contractMetrics(contract) const tags = parseTags(`${question} ${description}`).map((tag) => `#${tag}`) @@ -135,9 +138,11 @@ export function ContractDetails(props: { contract: Contract }) { return ( -
- -
+
{resolvedDate ? `${createdDate} - ${resolvedDate}` : createdDate} diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index 572f7bc5..b9f1e800 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -31,6 +31,7 @@ import { formatMoney } from '../lib/util/format' import { ResolutionOrChance } from './contract-card' import { SiteLink } from './site-link' import { Col } from './layout/col' +import { UserLink } from './user-page' dayjs.extend(relativeTime) function FeedComment(props: { activityItem: any }) { @@ -205,6 +206,8 @@ export function ContractDescription(props: { function FeedQuestion(props: { contract: Contract }) { const { contract } = props + const { creatorName, creatorUsername, createdTime, question, resolution } = + contract const { probPercent } = contractMetrics(contract) return ( @@ -218,19 +221,23 @@ function FeedQuestion(props: { contract: Contract }) {
- {contract.creatorName} asked{' '} - + {' '} + asked
- {contract.question} + {question} @@ -242,6 +249,7 @@ function FeedQuestion(props: { contract: Contract }) { function FeedDescription(props: { contract: Contract }) { const { contract } = props + const { creatorName, creatorUsername } = contract const user = useUser() const isCreator = user?.id === contract.creatorId @@ -256,8 +264,12 @@ function FeedDescription(props: { contract: Contract }) {
- {contract.creatorName} created - this market + {' '} + created this market
@@ -280,6 +292,7 @@ function OutcomeIcon(props: { outcome?: 'YES' | 'NO' | 'CANCEL' }) { function FeedResolve(props: { contract: Contract }) { const { contract } = props + const { creatorName, creatorUsername } = contract const resolution = contract.resolution || 'CANCEL' return ( @@ -293,8 +306,12 @@ function FeedResolve(props: { contract: Contract }) {
- {contract.creatorName} resolved - this market to {' '} + {' '} + resolved this market to {' '}
diff --git a/web/components/user-page.tsx b/web/components/user-page.tsx index 3bf207b2..0a27fae6 100644 --- a/web/components/user-page.tsx +++ b/web/components/user-page.tsx @@ -7,12 +7,18 @@ import { SEO } from './SEO' import { Page } from './page' import { SiteLink } from './site-link' -export function UserLink(props: { username: string; className?: string }) { - const { username, className } = props +export function UserLink(props: { + name: string + username: string + showUsername?: boolean + className?: string +}) { + const { name, username, showUsername, className } = props return ( - @{username} + {name} + {showUsername && ` (@${username})`} ) }