diff --git a/web/components/following-button.tsx b/web/components/following-button.tsx index b5ae77a6..7c43c414 100644 --- a/web/components/following-button.tsx +++ b/web/components/following-button.tsx @@ -23,7 +23,7 @@ export function FollowingButton(props: { user: User }) { Following - setIsOpen(true)}> Following - - { prefetchUsers(discoverUserIds) }, [discoverUserIds]) @@ -122,7 +122,7 @@ function FollowingFollowersDialog(props: { ...(currentUser ? [ { - title: 'Discover', + title: 'Similar', content: , }, ] diff --git a/web/hooks/use-follows.ts b/web/hooks/use-follows.ts index bd3fae3e..e5a074d6 100644 --- a/web/hooks/use-follows.ts +++ b/web/hooks/use-follows.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react' import { listenForFollowers, listenForFollows } from 'web/lib/firebase/users' -export const useFollows = (userId: string | undefined) => { +export const useFollows = (userId: string | null | undefined) => { const [followIds, setFollowIds] = useState() useEffect(() => { diff --git a/web/hooks/use-users.ts b/web/hooks/use-users.ts index 428674ab..632a0336 100644 --- a/web/hooks/use-users.ts +++ b/web/hooks/use-users.ts @@ -5,7 +5,6 @@ import { listenForAllUsers, listenForPrivateUsers, } from 'web/lib/firebase/users' -import { useUser } from './use-user' import { groupBy, sortBy, difference } from 'lodash' import { getContractsOfUserBets } from 'web/lib/firebase/bets' import { useFollows } from './use-follows' @@ -42,14 +41,12 @@ export const usePrivateUsers = () => { return users } -export const useDiscoverUsers = () => { - const user = useUser() - +export const useDiscoverUsers = (userId: string | null | undefined) => { const [discoverUserIds, setDiscoverUserIds] = useState([]) useEffect(() => { - if (user) - getContractsOfUserBets(user.id).then((contracts) => { + if (userId) + getContractsOfUserBets(userId).then((contracts) => { const creatorCounts = Object.entries( groupBy(contracts, 'creatorId') ).map(([id, contracts]) => [id, contracts.length] as const) @@ -60,10 +57,10 @@ export const useDiscoverUsers = () => { setDiscoverUserIds(topCreatorIds) }) - }, [user]) + }, [userId]) - const followedUserIds = useFollows(user?.id) - const nonSuggestions = [user?.id ?? '', ...(followedUserIds ?? [])] + const followedUserIds = useFollows(userId) + const nonSuggestions = [userId ?? '', ...(followedUserIds ?? [])] return difference(discoverUserIds, nonSuggestions).slice(0, 50) }