Skip to content

Commit

Permalink
Keep comments stable, always on main contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sipec committed Sep 17, 2024
1 parent 1a3b70a commit cf988d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions web/components/contract/contract-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import { api } from 'web/lib/api/api'
import { TRADE_TERM } from 'common/envs/constants'

export function ContractTabs(props: {
contract: Contract
mainContract: Contract
liveContract: Contract
bets: Bet[]
comments: ContractComment[]
userPositionsByOutcome: ContractMetricsByOutcome
Expand All @@ -62,7 +63,8 @@ export function ContractTabs(props: {
appRouter?: boolean
}) {
const {
contract,
mainContract,
liveContract,
comments,
bets,
replyTo,
Expand Down Expand Up @@ -115,7 +117,7 @@ export function ContractTabs(props: {
title: commentsTitle,
content: (
<CommentsTabContent
contract={contract}
contract={mainContract}
comments={comments}
pinnedComments={pinnedComments}
setCommentsLength={setTotalComments}
Expand All @@ -129,20 +131,20 @@ export function ContractTabs(props: {
),
},
totalBets > 0 &&
(contract.mechanism === 'cpmm-1' ||
contract.mechanism === 'cpmm-multi-1') && {
(liveContract.mechanism === 'cpmm-1' ||
liveContract.mechanism === 'cpmm-multi-1') && {
title: positionsTitle,
content: (
<UserPositionsTable
key={contract.id}
key={liveContract.id}
positions={
// If contract is resolved, will have to refetch positions by profit
Object.values(userPositionsByOutcome).length > 0 &&
!contract.isResolved
!liveContract.isResolved
? userPositionsByOutcome
: undefined
}
contract={contract as BinaryContract}
contract={liveContract as BinaryContract}
setTotalPositions={setTotalPositions}
/>
),
Expand All @@ -152,8 +154,8 @@ export function ContractTabs(props: {
content: (
<Col className={'gap-4'}>
<BetsTabContent
key={contract.id}
contract={contract}
key={liveContract.id}
contract={liveContract}
bets={bets}
totalBets={totalBets}
setReplyToBet={setReplyTo}
Expand Down
3 changes: 2 additions & 1 deletion web/components/contract/twomba-contract-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ export function TwombaContractPageContent(props: ContractParams) {

<div ref={tabsContainerRef} className="mb-4">
<ContractTabs
contract={liveContract}
mainContract={props.contract}
liveContract={liveContract}
bets={bets}
totalBets={totalBets}
comments={comments}
Expand Down

0 comments on commit cf988d6

Please sign in to comment.