879ab272e0
* Create following button that opens follow list in modal. * Move react query deps to web package.json * UseFollowers hook * Following and followers button, dialog with tabs. * Fix line endings * Remove carriage return from default vscode eol * Add placeholder message if no users followed / no followers * Tweak spacing
23 lines
634 B
TypeScript
23 lines
634 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { listenForFollowers, listenForFollows } from 'web/lib/firebase/users'
|
|
|
|
export const useFollows = (userId: string | undefined) => {
|
|
const [followIds, setFollowIds] = useState<string[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (userId) return listenForFollows(userId, setFollowIds)
|
|
}, [userId])
|
|
|
|
return followIds
|
|
}
|
|
|
|
export const useFollowers = (userId: string | undefined) => {
|
|
const [followerIds, setFollowerIds] = useState<string[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (userId) return listenForFollowers(userId, setFollowerIds)
|
|
}, [userId])
|
|
|
|
return followerIds
|
|
}
|