Rename to "useFollowedFoldIds"

This commit is contained in:
Austin Chen 2022-03-29 09:38:56 -07:00
parent d326ae5c30
commit 6185e3b740
4 changed files with 7 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import clsx from 'clsx'
import { Fold } from '../../../common/fold'
import { useFollowedFolds } from '../../hooks/use-fold'
import { useFollowedFoldIds } from '../../hooks/use-fold'
import { useUser } from '../../hooks/use-user'
import { followFold, unfollowFold } from '../../lib/firebase/folds'
@ -9,7 +9,7 @@ export function FollowFoldButton(props: { fold: Fold; className?: string }) {
const user = useUser()
const followedFoldIds = useFollowedFolds(user)
const followedFoldIds = useFollowedFoldIds(user)
const following = followedFoldIds
? followedFoldIds.includes(fold.id)
: undefined

View File

@ -10,7 +10,7 @@ import { Comment, getRecentComments } from '../lib/firebase/comments'
import { Contract, getActiveContracts } from '../lib/firebase/contracts'
import { listAllFolds } from '../lib/firebase/folds'
import { useInactiveContracts } from './use-contracts'
import { useFollowedFolds } from './use-fold'
import { useFollowedFoldIds } from './use-fold'
import { useSeenContracts } from './use-seen-contracts'
import { useUserBetContracts } from './use-user-bets'
@ -48,7 +48,7 @@ export const useFilterYourContracts = (
folds: Fold[],
contracts: Contract[]
) => {
const followedFoldIds = useFollowedFolds(user)
const followedFoldIds = useFollowedFoldIds(user)
const followedFolds = filterDefined(
(followedFoldIds ?? []).map((id) => folds.find((fold) => fold.id === id))

View File

@ -50,7 +50,7 @@ export const useFollowingFold = (fold: Fold, user: User | null | undefined) => {
}
// Note: We cache FollowedFolds in localstorage to speed up the initial load
export const useFollowedFolds = (user: User | null | undefined) => {
export const useFollowedFoldIds = (user: User | null | undefined) => {
const [followedFoldIds, setFollowedFoldIds] = useState<string[] | undefined>(
undefined
)

View File

@ -7,11 +7,10 @@ import { FollowFoldButton } from '../components/folds/follow-fold-button'
import { Col } from '../components/layout/col'
import { Row } from '../components/layout/row'
import { Page } from '../components/page'
import { SiteLink } from '../components/site-link'
import { TagsList } from '../components/tags-list'
import { Title } from '../components/title'
import { UserLink } from '../components/user-page'
import { useFolds, useFollowedFolds } from '../hooks/use-fold'
import { useFolds, useFollowedFoldIds } from '../hooks/use-fold'
import { useUser } from '../hooks/use-user'
import { foldPath, listAllFolds } from '../lib/firebase/folds'
import { getUser, User } from '../lib/firebase/users'
@ -44,7 +43,7 @@ export default function Folds(props: {
let folds = useFolds() ?? props.folds
const user = useUser()
const followedFoldIds = useFollowedFolds(user) || []
const followedFoldIds = useFollowedFoldIds(user) || []
// First sort by follower count, then list followed folds first
folds = _.sortBy(folds, (fold) => -1 * fold.followCount)
folds = _.sortBy(folds, (fold) => !followedFoldIds.includes(fold.id))