Show bets where you can add a comment on contract page feed.
This commit is contained in:
parent
404f3a6b0c
commit
eaa1a26af4
|
@ -44,6 +44,10 @@ import { Avatar } from './avatar'
|
||||||
import { useAdmin } from '../hooks/use-admin'
|
import { useAdmin } from '../hooks/use-admin'
|
||||||
import { Answer } from '../../common/answer'
|
import { Answer } from '../../common/answer'
|
||||||
|
|
||||||
|
const canAddComment = (createdTime: number, isSelf: boolean) => {
|
||||||
|
return isSelf && Date.now() - createdTime < 60 * 60 * 1000
|
||||||
|
}
|
||||||
|
|
||||||
function FeedComment(props: {
|
function FeedComment(props: {
|
||||||
activityItem: any
|
activityItem: any
|
||||||
moreHref: string
|
moreHref: string
|
||||||
|
@ -100,7 +104,7 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) {
|
||||||
const isSelf = user?.id == activityItem.userId
|
const isSelf = user?.id == activityItem.userId
|
||||||
const isCreator = contract.creatorId == activityItem.userId
|
const isCreator = contract.creatorId == activityItem.userId
|
||||||
// You can comment if your bet was posted in the last hour
|
// You can comment if your bet was posted in the last hour
|
||||||
const canComment = isSelf && Date.now() - createdTime < 60 * 60 * 1000
|
const canComment = canAddComment(createdTime, isSelf)
|
||||||
|
|
||||||
const [comment, setComment] = useState('')
|
const [comment, setComment] = useState('')
|
||||||
async function submitComment() {
|
async function submitComment() {
|
||||||
|
@ -132,7 +136,6 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<div className={clsx('min-w-0 flex-1 pb-1.5', !answer && 'pt-1.5')}>
|
<div className={clsx('min-w-0 flex-1 pb-1.5', !answer && 'pt-1.5')}>
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
<span>
|
<span>
|
||||||
|
@ -141,6 +144,11 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) {
|
||||||
{bought} {money}
|
{bought} {money}
|
||||||
<MaybeOutcomeLabel outcome={outcome} feedType={feedType} />
|
<MaybeOutcomeLabel outcome={outcome} feedType={feedType} />
|
||||||
<Timestamp time={createdTime} />
|
<Timestamp time={createdTime} />
|
||||||
|
{answer && (
|
||||||
|
<div className="text-neutral mt-1" style={{ fontSize: 15 }}>
|
||||||
|
{answer.text}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{canComment && (
|
{canComment && (
|
||||||
// Allow user to comment in an textarea if they are the creator
|
// Allow user to comment in an textarea if they are the creator
|
||||||
<div className="mt-2">
|
<div className="mt-2">
|
||||||
|
@ -167,8 +175,6 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{answer && <div style={{ fontSize: 15 }}>{answer.text}</div>}
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -815,10 +821,12 @@ export function ContractFeed(props: {
|
||||||
if (feedType === 'multi') {
|
if (feedType === 'multi') {
|
||||||
bets = bets.filter((bet) => bet.outcome === outcome)
|
bets = bets.filter((bet) => bet.outcome === outcome)
|
||||||
} else if (outcomeType === 'FREE_RESPONSE') {
|
} else if (outcomeType === 'FREE_RESPONSE') {
|
||||||
// Keep bets on comments or your own bets.
|
// Keep bets on comments or your bets where you can comment.
|
||||||
const commentBetIds = new Set(comments.map((comment) => comment.betId))
|
const commentBetIds = new Set(comments.map((comment) => comment.betId))
|
||||||
bets = bets.filter(
|
bets = bets.filter(
|
||||||
(bet) => commentBetIds.has(bet.id) || user?.id === bet.id
|
(bet) =>
|
||||||
|
commentBetIds.has(bet.id) ||
|
||||||
|
canAddComment(bet.createdTime, user?.id === bet.userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user