From 95242d94acfe23e94a2f9967df9c14aca6238389 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 16 Feb 2022 00:08:16 -0600 Subject: [PATCH 01/14] sort trades by resolved --- web/components/bets-list.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 13f9e596..f101105d 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -33,7 +33,7 @@ import { sellBet } from '../lib/firebase/api-call' import { ConfirmationButton } from './confirmation-button' import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' -type BetSort = 'newest' | 'profit' +type BetSort = 'newest' | 'profit' | 'resolved' export function BetsList(props: { user: User }) { const { user } = props @@ -111,6 +111,8 @@ export function BetsList(props: { user: User }) { (c) => c.isResolved ) + const displayedContracts = sort === 'resolved' ? resolved : unresolved + const currentInvestment = _.sumBy( unresolved, (c) => contractsInvestment[c.id] @@ -161,10 +163,11 @@ export function BetsList(props: { user: User }) { > + - {[...unresolved, ...resolved].map((contract) => ( + {displayedContracts.map((contract) => ( Date: Wed, 16 Feb 2022 10:32:44 -0800 Subject: [PATCH 02/14] Don't include trailing !:,.; in links --- web/components/linkify.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/components/linkify.tsx b/web/components/linkify.tsx index a1b617ad..21567b59 100644 --- a/web/components/linkify.tsx +++ b/web/components/linkify.tsx @@ -2,9 +2,11 @@ import { Fragment } from 'react' import { SiteLink } from './site-link' // Return a JSX span, linkifying @username, #hashtags, and https://... +// TODO: Use a markdown parser instead of rolling our own here. export function Linkify(props: { text: string; gray?: boolean }) { const { text, gray } = props - const regex = /(?:^|\s)(?:[@#][a-z0-9_]+|https?:\/\/\S+)/gi + const regex = + /(?:^|\s)(?:[@#][a-z0-9_]+|https?:\/\/[-A-Za-z0-9+&@#\/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#\/%=~_()|])/gi const matches = text.match(regex) || [] const links = matches.map((match) => { // Matches are in the form: " @username" or "https://example.com" From 2f7ab1842916bc903e60231cbf45b934db2f2658 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 16 Feb 2022 18:48:59 -0800 Subject: [PATCH 03/14] Stop flooring inputs into formatMoney --- web/components/amount-input.tsx | 2 +- web/components/profile-menu.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index dcc29465..0a1c5431 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -79,7 +79,7 @@ export function AmountInput(props: { Remaining balance -
{formatMoney(Math.floor(remainingBalance))}
+
{formatMoney(remainingBalance)}
{user.balance !== 1000 && }
diff --git a/web/components/profile-menu.tsx b/web/components/profile-menu.tsx index 50d2fcbc..1ded6378 100644 --- a/web/components/profile-menu.tsx +++ b/web/components/profile-menu.tsx @@ -87,7 +87,7 @@ function ProfileSummary(props: { user: User | undefined }) {
{user?.name}
- {user ? formatMoney(Math.floor(user.balance)) : ' '} + {user ? formatMoney(user.balance) : ' '}
From 87a33933e41c706e51f68e4a0448377513d013d4 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 16 Feb 2022 19:14:12 -0800 Subject: [PATCH 04/14] Revert "Stop flooring inputs into formatMoney" This reverts commit 2f7ab1842916bc903e60231cbf45b934db2f2658. --- web/components/amount-input.tsx | 2 +- web/components/profile-menu.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index 0a1c5431..dcc29465 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -79,7 +79,7 @@ export function AmountInput(props: { Remaining balance -
{formatMoney(remainingBalance)}
+
{formatMoney(Math.floor(remainingBalance))}
{user.balance !== 1000 && }
diff --git a/web/components/profile-menu.tsx b/web/components/profile-menu.tsx index 1ded6378..50d2fcbc 100644 --- a/web/components/profile-menu.tsx +++ b/web/components/profile-menu.tsx @@ -87,7 +87,7 @@ function ProfileSummary(props: { user: User | undefined }) {
{user?.name}
- {user ? formatMoney(user.balance) : ' '} + {user ? formatMoney(Math.floor(user.balance)) : ' '}
From 515676f885ad231ea5622dc22b63bd6d2ea960cc Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 16 Feb 2022 19:19:11 -0800 Subject: [PATCH 05/14] Consistently floor user.balance --- web/components/bets-list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index f101105d..e68d4fbc 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -144,7 +144,7 @@ export function BetsList(props: { user: User }) {
Balance
- {formatMoney(user.balance)}{' '} + {formatMoney(Math.floor(user.balance))}{' '}
From a12a8bcd6a6ec6735e14ef9f897b9011957b2f7e Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 16 Feb 2022 19:37:54 -0800 Subject: [PATCH 06/14] Expand create panel on focus From Richard Hanania's feedback --- web/components/feed-create.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/components/feed-create.tsx b/web/components/feed-create.tsx index a2d52135..7ed1a213 100644 --- a/web/components/feed-create.tsx +++ b/web/components/feed-create.tsx @@ -61,6 +61,7 @@ export default function FeedCreate(props: { }) { const { user, tag, className } = props const [question, setQuestion] = useState('') + const [focused, setFocused] = useState(false) const placeholders = [ 'Will anyone I know get engaged this year?', @@ -81,7 +82,11 @@ export default function FeedCreate(props: { return (
!question && inputRef.current?.focus()} >
@@ -99,17 +104,19 @@ export default function FeedCreate(props: { value={question} onClick={(e) => e.stopPropagation()} onChange={(e) => setQuestion(e.target.value.replace('\n', ''))} + onFocus={() => setFocused(true)} + onBlur={() => setFocused(false)} />
{/* Hide component instead of deleting, so edits to NewContract don't get lost */} -
+
{/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/} - {!question && ( + {!(question || focused) && (