Merge branch 'main' into close-emails

This commit is contained in:
mantikoros 2022-02-17 01:06:32 -06:00
commit 4264985591
5 changed files with 26 additions and 9 deletions

View File

@ -86,7 +86,8 @@ Questions? Feedback? I'd love to hear from you - just reply to this email!
Or come chat with us on Discord: https://discord.gg/eHQBNBqXuh Or come chat with us on Discord: https://discord.gg/eHQBNBqXuh
Best, Best,
Austin from Manifold` Austin from Manifold
https://manifold.markets/`
) )
} }

View File

@ -33,7 +33,7 @@ import { sellBet } from '../lib/firebase/api-call'
import { ConfirmationButton } from './confirmation-button' import { ConfirmationButton } from './confirmation-button'
import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label'
type BetSort = 'newest' | 'profit' type BetSort = 'newest' | 'profit' | 'resolved'
export function BetsList(props: { user: User }) { export function BetsList(props: { user: User }) {
const { user } = props const { user } = props
@ -111,6 +111,8 @@ export function BetsList(props: { user: User }) {
(c) => c.isResolved (c) => c.isResolved
) )
const displayedContracts = sort === 'resolved' ? resolved : unresolved
const currentInvestment = _.sumBy( const currentInvestment = _.sumBy(
unresolved, unresolved,
(c) => contractsInvestment[c.id] (c) => contractsInvestment[c.id]
@ -142,7 +144,7 @@ export function BetsList(props: { user: User }) {
<Col> <Col>
<div className="text-sm text-gray-500">Balance</div> <div className="text-sm text-gray-500">Balance</div>
<div className="whitespace-nowrap text-lg"> <div className="whitespace-nowrap text-lg">
{formatMoney(user.balance)}{' '} {formatMoney(Math.floor(user.balance))}{' '}
</div> </div>
</Col> </Col>
<Col> <Col>
@ -161,10 +163,11 @@ export function BetsList(props: { user: User }) {
> >
<option value="profit">By profit</option> <option value="profit">By profit</option>
<option value="newest">Newest</option> <option value="newest">Newest</option>
<option value="resolved">Resolved</option>
</select> </select>
</Col> </Col>
{[...unresolved, ...resolved].map((contract) => ( {displayedContracts.map((contract) => (
<MyContractBets <MyContractBets
key={contract.id} key={contract.id}
contract={contract} contract={contract}

View File

@ -61,6 +61,7 @@ export default function FeedCreate(props: {
}) { }) {
const { user, tag, className } = props const { user, tag, className } = props
const [question, setQuestion] = useState('') const [question, setQuestion] = useState('')
const [focused, setFocused] = useState(false)
const placeholders = [ const placeholders = [
'Will anyone I know get engaged this year?', 'Will anyone I know get engaged this year?',
@ -81,7 +82,11 @@ export default function FeedCreate(props: {
return ( return (
<div <div
className={clsx('mt-2 w-full bg-white p-4 shadow-md', className)} className={clsx(
'mt-2 w-full rounded bg-white p-4 shadow-md',
question || focused ? 'ring-2 ring-indigo-300' : '',
className
)}
onClick={() => !question && inputRef.current?.focus()} onClick={() => !question && inputRef.current?.focus()}
> >
<div className="relative flex items-start space-x-3"> <div className="relative flex items-start space-x-3">
@ -99,17 +104,19 @@ export default function FeedCreate(props: {
value={question} value={question}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
onChange={(e) => setQuestion(e.target.value.replace('\n', ''))} onChange={(e) => setQuestion(e.target.value.replace('\n', ''))}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/> />
</div> </div>
</div> </div>
{/* Hide component instead of deleting, so edits to NewContract don't get lost */} {/* Hide component instead of deleting, so edits to NewContract don't get lost */}
<div className={question ? '' : 'hidden'}> <div className={question || focused ? '' : 'hidden'}>
<NewContract question={question} tag={tag} /> <NewContract question={question} tag={tag} />
</div> </div>
{/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/} {/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/}
{!question && ( {!(question || focused) && (
<div className="flex justify-end"> <div className="flex justify-end">
<button className="btn btn-sm" disabled> <button className="btn btn-sm" disabled>
Create Market Create Market

View File

@ -2,9 +2,11 @@ import { Fragment } from 'react'
import { SiteLink } from './site-link' import { SiteLink } from './site-link'
// Return a JSX span, linkifying @username, #hashtags, and https://... // 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 }) { export function Linkify(props: { text: string; gray?: boolean }) {
const { text, gray } = props 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 matches = text.match(regex) || []
const links = matches.map((match) => { const links = matches.map((match) => {
// Matches are in the form: " @username" or "https://example.com" // Matches are in the form: " @username" or "https://example.com"

View File

@ -25,11 +25,15 @@ import { useFollowedFolds } from '../hooks/use-fold'
import { SiteLink } from '../components/site-link' import { SiteLink } from '../components/site-link'
export async function getStaticProps() { export async function getStaticProps() {
const [contracts, folds] = await Promise.all([ let [contracts, folds] = await Promise.all([
listAllContracts().catch((_) => []), listAllContracts().catch((_) => []),
listAllFolds().catch(() => []), listAllFolds().catch(() => []),
]) ])
// TODO(James): Remove this line. We are filtering out non-binary contracts so that
// branches other than free-response work.
contracts = contracts.filter((contract) => contract.outcomeType === 'BINARY')
const [contractBets, contractComments] = await Promise.all([ const [contractBets, contractComments] = await Promise.all([
Promise.all(contracts.map((contract) => listAllBets(contract.id))), Promise.all(contracts.map((contract) => listAllBets(contract.id))),
Promise.all(contracts.map((contract) => listAllComments(contract.id))), Promise.all(contracts.map((contract) => listAllComments(contract.id))),