manifold/web/hooks/use-comments.ts
Austin Chen 07ce27f20b
Show activity feed on each market & allow comments on your bets (#18)
* Copy feed template from TailwindUI

* Show all bets in a feed-like manner

* Tweak design of individual trades

* Allow traders to comment on their bets

* Code cleanups

* Incorporate contract description into the feed

* Support description editing from contract feed

* Group together bets placed within 24h

* Fix build error

* Add a feed item for market resolution

* Add a feed item for markets that have closed

* Comment on a separate subcollection
2022-01-03 23:21:14 -08:00

13 lines
376 B
TypeScript

import { useEffect, useState } from 'react'
import { Comment, listenForComments } from '../lib/firebase/comments'
export const useComments = (contractId: string) => {
const [comments, setComments] = useState<Comment[] | 'loading'>('loading')
useEffect(() => {
if (contractId) return listenForComments(contractId, setComments)
}, [contractId])
return comments
}