diff --git a/web/components/contract/contract-overview.tsx b/web/components/contract/contract-overview.tsx
index bba30776..cf6e135e 100644
--- a/web/components/contract/contract-overview.tsx
+++ b/web/components/contract/contract-overview.tsx
@@ -22,6 +22,7 @@ import { ContractDescription } from './contract-description'
import { ContractDetails } from './contract-details'
import { NumericGraph } from './numeric-graph'
import { ShareRow } from './share-row'
+import { FollowMarketButton } from 'web/components/follow-market-button'
export const ContractOverview = (props: {
contract: Contract
@@ -44,37 +45,42 @@ export const ContractOverview = (props: {
+
+
- {isBinary && (
-
- )}
+ {isBinary && (
+
+ )}
- {isPseudoNumeric && (
-
- )}
+ {isPseudoNumeric && (
+
+ )}
- {outcomeType === 'NUMERIC' && (
-
- )}
+ {outcomeType === 'NUMERIC' && (
+
+ )}
+
{isBinary ? (
-
- {tradingAllowed(contract) && (
-
- )}
+
+
+ {tradingAllowed(contract) && (
+
+ )}
+
) : isPseudoNumeric ? (
diff --git a/web/components/contract/share-row.tsx b/web/components/contract/share-row.tsx
index a45f0459..9011ff1b 100644
--- a/web/components/contract/share-row.tsx
+++ b/web/components/contract/share-row.tsx
@@ -1,8 +1,8 @@
import clsx from 'clsx'
-import { EyeIcon, EyeOffIcon, ShareIcon } from '@heroicons/react/outline'
+import { ShareIcon } from '@heroicons/react/outline'
import { Row } from '../layout/row'
-import { Contract, contracts } from 'web/lib/firebase/contracts'
+import { Contract } from 'web/lib/firebase/contracts'
import { useState } from 'react'
import { Button } from 'web/components/button'
import { CreateChallengeModal } from '../challenges/create-challenge-modal'
@@ -10,8 +10,6 @@ import { User } from 'common/user'
import { CHALLENGES_ENABLED } from 'common/challenge'
import { ShareModal } from './share-modal'
import { withTracking } from 'web/lib/service/analytics'
-import { collection, deleteDoc, doc, setDoc } from 'firebase/firestore'
-import { useContractFollows } from 'web/hooks/use-follows'
export function ShareRow(props: {
contract: Contract
@@ -25,7 +23,6 @@ export function ShareRow(props: {
const [isOpen, setIsOpen] = useState(false)
const [isShareOpen, setShareOpen] = useState(false)
- const followers = useContractFollows(contract.id)
return (
@@ -65,42 +62,6 @@ export function ShareRow(props: {
/>
)}
- {user && (
-
- )}
)
}
diff --git a/web/components/follow-market-button.tsx b/web/components/follow-market-button.tsx
new file mode 100644
index 00000000..92803d6c
--- /dev/null
+++ b/web/components/follow-market-button.tsx
@@ -0,0 +1,53 @@
+import { Button } from 'web/components/button'
+import {
+ Contract,
+ followContract,
+ unFollowContract,
+} from 'web/lib/firebase/contracts'
+import toast from 'react-hot-toast'
+import { CheckIcon, HeartIcon } from '@heroicons/react/outline'
+import clsx from 'clsx'
+import { User } from 'common/user'
+import { useContractFollows } from 'web/hooks/use-follows'
+import { firebaseLogin } from 'web/lib/firebase/users'
+
+export const FollowMarketButton = (props: {
+ contract: Contract
+ user: User | undefined | null
+}) => {
+ const { contract, user } = props
+ const followers = useContractFollows(contract.id)
+
+ return (
+
+ )
+}
diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts
index 6e253a19..fc205b6a 100644
--- a/web/lib/firebase/contracts.ts
+++ b/web/lib/firebase/contracts.ts
@@ -222,6 +222,19 @@ export function listenForContractFollows(
)
}
+export async function followContract(contractId: string, userId: string) {
+ const followDoc = doc(collection(contracts, contractId, 'follows'), userId)
+ return await setDoc(followDoc, {
+ id: userId,
+ createdTime: Date.now(),
+ })
+}
+
+export async function unFollowContract(contractId: string, userId: string) {
+ const followDoc = doc(collection(contracts, contractId, 'follows'), userId)
+ await deleteDoc(followDoc)
+}
+
function chooseRandomSubset(contracts: Contract[], count: number) {
const fiveMinutes = 5 * 60 * 1000
const seed = Math.round(Date.now() / fiveMinutes).toString()