added follow verification, put back in watch/tip buttons

This commit is contained in:
ingawei 2022-09-14 22:59:53 -07:00
parent 957f880221
commit 66fbd0a56d
4 changed files with 46 additions and 26 deletions

View File

@ -160,7 +160,7 @@ export function ContractDetails(props: {
</Row> </Row>
<Row className="text-2xs text-greyscale-4 gap-2 sm:text-xs"> <Row className="text-2xs text-greyscale-4 gap-2 sm:text-xs">
{(!!closeTime || !!resolvedDate) && ( {(!!closeTime || !!resolvedDate) && (
<Row className="items-center gap-1"> <Row className="select-none items-center gap-1">
{resolvedDate && resolutionTime ? ( {resolvedDate && resolutionTime ? (
<> <>
<DateTimeTooltip <DateTimeTooltip
@ -169,15 +169,15 @@ export function ContractDetails(props: {
> >
<Row> <Row>
<div>resolved&nbsp;</div> <div>resolved&nbsp;</div>
<b>{resolvedDate}</b> {resolvedDate}
</Row> </Row>
</DateTimeTooltip> </DateTimeTooltip>
</> </>
) : null} ) : null}
{!resolvedDate && closeTime && user && ( {!resolvedDate && closeTime && (
<Row> <Row>
<div>Closes&nbsp;</div> <div>closes&nbsp;</div>
<EditableCloseDate <EditableCloseDate
closeTime={closeTime} closeTime={closeTime}
contract={contract} contract={contract}

View File

@ -86,15 +86,7 @@ export function ContractInfoDialog(props: {
<Modal open={open} setOpen={setOpen}> <Modal open={open} setOpen={setOpen}>
<Col className="gap-4 rounded bg-white p-6"> <Col className="gap-4 rounded bg-white p-6">
<Row className="w-full justify-between"> <Title className="!mt-0 !mb-0" text="This Market" />
<Title className="!mt-0 !mb-0" text="This Market" />
<div>
<FollowMarketButton contract={contract} user={user} />
{user?.id !== contract.creatorId && (
<LikeMarketButton contract={contract} user={user} />
)}
</div>
</Row>
<table className="table-compact table-zebra table w-full text-gray-500"> <table className="table-compact table-zebra table w-full text-gray-500">
<tbody> <tbody>

View File

@ -15,6 +15,7 @@ import { withTracking } from 'web/lib/service/analytics'
import { CreateChallengeModal } from 'web/components/challenges/create-challenge-modal' import { CreateChallengeModal } from 'web/components/challenges/create-challenge-modal'
import { CHALLENGES_ENABLED } from 'common/challenge' import { CHALLENGES_ENABLED } from 'common/challenge'
import ChallengeIcon from 'web/lib/icons/challenge-icon' import ChallengeIcon from 'web/lib/icons/challenge-icon'
import { getIsMobile } from './contract-details'
export function ExtraContractActionsRow(props: { contract: Contract }) { export function ExtraContractActionsRow(props: { contract: Contract }) {
const { contract } = props const { contract } = props
@ -28,6 +29,10 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
return ( return (
<Row> <Row>
<FollowMarketButton contract={contract} user={user} />
{user?.id !== contract.creatorId && (
<LikeMarketButton contract={contract} user={user} />
)}
<Button <Button
size="sm" size="sm"
color="gray-white" color="gray-white"

View File

@ -1,6 +1,6 @@
import { CheckCircleIcon, PlusCircleIcon } from '@heroicons/react/solid' import { CheckCircleIcon, PlusCircleIcon } from '@heroicons/react/solid'
import clsx from 'clsx' import clsx from 'clsx'
import { useEffect, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { useFollows } from 'web/hooks/use-follows' import { useFollows } from 'web/hooks/use-follows'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { follow, unfollow } from 'web/lib/firebase/users' import { follow, unfollow } from 'web/lib/firebase/users'
@ -76,14 +76,41 @@ export function UserFollowButton(props: { userId: string; small?: boolean }) {
export function MiniUserFollowButton(props: { userId: string }) { export function MiniUserFollowButton(props: { userId: string }) {
const { userId } = props const { userId } = props
const currentUser = useUser()
const following = useFollows(currentUser?.id)
const isFollowing = following?.includes(userId)
const user = useUser() const user = useUser()
const following = useFollows(user?.id)
const isFollowing = following?.includes(userId)
const isFirstRender = useRef(true)
const [justFollowed, setJustFollowed] = useState(false)
// const [followFade, setfollowFade] = useState(false)
useEffect(() => {
if (isFirstRender.current) {
if (isFollowing != undefined) {
isFirstRender.current = false
}
return
}
if (isFollowing) {
setJustFollowed(true)
setTimeout(() => {
setJustFollowed(false)
}, 1000)
}
}, [isFollowing])
if (justFollowed) {
return (
<CheckCircleIcon
className={clsx(
'text-highlight-blue ml-3 mt-2 h-5 w-5 rounded-full bg-white sm:mr-2'
)}
aria-hidden="true"
/>
)
}
if ( if (
!currentUser || !user ||
currentUser.id === userId || user.id === userId ||
isFollowing || isFollowing ||
!user || !user ||
isFollowing === undefined isFollowing === undefined
@ -91,18 +118,14 @@ export function MiniUserFollowButton(props: { userId: string }) {
return null return null
return ( return (
<> <>
<Button <button onClick={withTracking(() => follow(user.id, userId), 'follow')}>
size="sm"
color="highlight-blue"
onClick={withTracking(() => follow(currentUser.id, userId), 'follow')}
>
<PlusCircleIcon <PlusCircleIcon
className={clsx( className={clsx(
'hover:text-hover-blue h-5 w-5 rounded-full bg-white sm:mr-2' 'text-highlight-blue hover:text-hover-blue mt-2 ml-3 h-5 w-5 rounded-full bg-white sm:mr-2'
)} )}
aria-hidden="true" aria-hidden="true"
/> />
</Button> </button>
</> </>
) )
} }