2022-06-03 04:52:14 +00:00
|
|
|
import { useEffect, useState } from 'react'
|
2022-06-08 03:24:18 +00:00
|
|
|
import { listenForFollowers, listenForFollows } from 'web/lib/firebase/users'
|
2022-06-03 04:52:14 +00:00
|
|
|
|
|
|
|
export const useFollows = (userId: string | undefined) => {
|
|
|
|
const [followIds, setFollowIds] = useState<string[] | undefined>()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (userId) return listenForFollows(userId, setFollowIds)
|
|
|
|
}, [userId])
|
|
|
|
|
|
|
|
return followIds
|
|
|
|
}
|
2022-06-08 03:24:18 +00:00
|
|
|
|
|
|
|
export const useFollowers = (userId: string | undefined) => {
|
|
|
|
const [followerIds, setFollowerIds] = useState<string[] | undefined>()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (userId) return listenForFollowers(userId, setFollowerIds)
|
|
|
|
}, [userId])
|
|
|
|
|
|
|
|
return followerIds
|
|
|
|
}
|