5b431226d4
* Tracks all market activity on a single page * Support both global and per-contract feeds * UI tweaks * Include contract description in activity feed * Show activity feed on Create page
23 lines
622 B
TypeScript
23 lines
622 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import {
|
|
Comment,
|
|
listenForComments,
|
|
listenForRecentComments,
|
|
} 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
|
|
}
|
|
|
|
export const useRecentComments = () => {
|
|
const [recentComments, setRecentComments] = useState<Comment[] | undefined>()
|
|
useEffect(() => listenForRecentComments(setRecentComments), [])
|
|
return recentComments
|
|
}
|