Add see more button, description to explore items
This commit is contained in:
parent
4169b335d8
commit
c78df4abde
|
@ -1,5 +1,9 @@
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { ContractActivityFeed, ContractSummaryFeed } from './contract-feed'
|
import {
|
||||||
|
ContractActivityFeed,
|
||||||
|
ContractFeed,
|
||||||
|
ContractSummaryFeed,
|
||||||
|
} from './contract-feed'
|
||||||
import { Contract } from '../lib/firebase/contracts'
|
import { Contract } from '../lib/firebase/contracts'
|
||||||
import { Comment } from '../lib/firebase/comments'
|
import { Comment } from '../lib/firebase/comments'
|
||||||
import { Col } from './layout/col'
|
import { Col } from './layout/col'
|
||||||
|
@ -73,8 +77,10 @@ export function ActivityFeed(props: {
|
||||||
contracts: Contract[]
|
contracts: Contract[]
|
||||||
recentBets: Bet[]
|
recentBets: Bet[]
|
||||||
recentComments: Comment[]
|
recentComments: Comment[]
|
||||||
|
loadBetAndCommentHistory?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contracts, recentBets, recentComments } = props
|
const { contracts, recentBets, recentComments, loadBetAndCommentHistory } =
|
||||||
|
props
|
||||||
|
|
||||||
const groupedBets = _.groupBy(recentBets, (bet) => bet.contractId)
|
const groupedBets = _.groupBy(recentBets, (bet) => bet.contractId)
|
||||||
const groupedComments = _.groupBy(
|
const groupedComments = _.groupBy(
|
||||||
|
@ -86,13 +92,22 @@ export function ActivityFeed(props: {
|
||||||
<Col className="items-center">
|
<Col className="items-center">
|
||||||
<Col className="w-full">
|
<Col className="w-full">
|
||||||
<Col className="w-full divide-y divide-gray-300 self-center bg-white">
|
<Col className="w-full divide-y divide-gray-300 self-center bg-white">
|
||||||
{contracts.map((contract, i) => (
|
{contracts.map((contract) => (
|
||||||
<div key={contract.id} className="py-6 px-2 sm:px-4">
|
<div key={contract.id} className="py-6 px-2 sm:px-4">
|
||||||
<ContractActivityFeed
|
{loadBetAndCommentHistory ? (
|
||||||
contract={contract}
|
<ContractFeed
|
||||||
bets={groupedBets[contract.id] ?? []}
|
contract={contract}
|
||||||
comments={groupedComments[contract.id] ?? []}
|
bets={groupedBets[contract.id] ?? []}
|
||||||
/>
|
comments={groupedComments[contract.id] ?? []}
|
||||||
|
feedType="activity"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ContractActivityFeed
|
||||||
|
contract={contract}
|
||||||
|
bets={groupedBets[contract.id] ?? []}
|
||||||
|
comments={groupedComments[contract.id] ?? []}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
|
@ -304,8 +304,11 @@ function TruncatedComment(props: {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function FeedQuestion(props: { contract: Contract }) {
|
function FeedQuestion(props: {
|
||||||
const { contract } = props
|
contract: Contract
|
||||||
|
showDescription?: boolean
|
||||||
|
}) {
|
||||||
|
const { contract, showDescription } = props
|
||||||
const { creatorName, creatorUsername, question, resolution, outcomeType } =
|
const { creatorName, creatorUsername, question, resolution, outcomeType } =
|
||||||
contract
|
contract
|
||||||
const { truePool } = contractMetrics(contract)
|
const { truePool } = contractMetrics(contract)
|
||||||
|
@ -341,16 +344,33 @@ function FeedQuestion(props: { contract: Contract }) {
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Col className="items-start justify-between gap-2 sm:flex-row sm:gap-4">
|
<Col className="items-start justify-between gap-2 sm:flex-row sm:gap-4">
|
||||||
<SiteLink
|
<Col>
|
||||||
href={contractPath(contract)}
|
<SiteLink
|
||||||
className="text-lg text-indigo-700 sm:text-xl"
|
href={contractPath(contract)}
|
||||||
>
|
className="text-lg text-indigo-700 sm:text-xl"
|
||||||
{question}
|
>
|
||||||
</SiteLink>
|
{question}
|
||||||
|
</SiteLink>
|
||||||
|
{!showDescription && (
|
||||||
|
<SiteLink
|
||||||
|
href={contractPath(contract)}
|
||||||
|
className="text-sm relative top-4"
|
||||||
|
>
|
||||||
|
<div className="text-gray-500 pb-1.5">See more...</div>
|
||||||
|
</SiteLink>
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
{(isBinary || resolution) && (
|
{(isBinary || resolution) && (
|
||||||
<ResolutionOrChance className="items-center" contract={contract} />
|
<ResolutionOrChance className="items-center" contract={contract} />
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
{showDescription && (
|
||||||
|
<TruncatedComment
|
||||||
|
comment={contract.description}
|
||||||
|
moreHref={contractPath(contract)}
|
||||||
|
shouldTruncate
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -705,7 +725,7 @@ function FeedItems(props: {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flow-root pr-2 md:pr-0">
|
<div className="flow-root pr-2 md:pr-0">
|
||||||
<div className={clsx(tradingAllowed(contract) ? '' : '-mb-8')}>
|
<div className={clsx(tradingAllowed(contract) ? '' : '-mb-6')}>
|
||||||
{items.map((activityItem, activityItemIdx) => (
|
{items.map((activityItem, activityItemIdx) => (
|
||||||
<div key={activityItem.id} className="relative pb-6">
|
<div key={activityItem.id} className="relative pb-6">
|
||||||
{activityItemIdx !== items.length - 1 ? (
|
{activityItemIdx !== items.length - 1 ? (
|
||||||
|
@ -875,7 +895,7 @@ export function ContractSummaryFeed(props: {
|
||||||
<div className={clsx(tradingAllowed(contract) ? '' : '-mb-8')}>
|
<div className={clsx(tradingAllowed(contract) ? '' : '-mb-8')}>
|
||||||
<div className="relative pb-8">
|
<div className="relative pb-8">
|
||||||
<div className="relative flex items-start space-x-3">
|
<div className="relative flex items-start space-x-3">
|
||||||
<FeedQuestion contract={contract} />
|
<FeedQuestion contract={contract} showDescription />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -234,6 +234,7 @@ export default function FoldPage(props: {
|
||||||
contracts={activeContracts}
|
contracts={activeContracts}
|
||||||
recentBets={recentBets ?? []}
|
recentBets={recentBets ?? []}
|
||||||
recentComments={recentComments ?? []}
|
recentComments={recentComments ?? []}
|
||||||
|
loadBetAndCommentHistory
|
||||||
/>
|
/>
|
||||||
{activeContracts.length === 0 && (
|
{activeContracts.length === 0 && (
|
||||||
<div className="mx-2 mt-4 text-gray-500 lg:mx-0">
|
<div className="mx-2 mt-4 text-gray-500 lg:mx-0">
|
||||||
|
|
|
@ -57,7 +57,7 @@ const Home = (props: {
|
||||||
const { activeContracts } = useFindActiveContracts({
|
const { activeContracts } = useFindActiveContracts({
|
||||||
contracts: yourContracts,
|
contracts: yourContracts,
|
||||||
recentBets: initialRecentBets ?? [],
|
recentBets: initialRecentBets ?? [],
|
||||||
recentComments,
|
recentComments: props.recentComments,
|
||||||
})
|
})
|
||||||
|
|
||||||
const exploreContracts = useExploreContracts()
|
const exploreContracts = useExploreContracts()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user