Change Similar tab to exclude people you follow

This commit is contained in:
James Grugett 2022-06-10 12:28:02 -05:00
parent a68e943d0b
commit f2c6c8c483

View File

@ -8,6 +8,7 @@ import {
import { groupBy, sortBy, difference } from 'lodash' import { groupBy, sortBy, difference } from 'lodash'
import { getContractsOfUserBets } from 'web/lib/firebase/bets' import { getContractsOfUserBets } from 'web/lib/firebase/bets'
import { useFollows } from './use-follows' import { useFollows } from './use-follows'
import { useUser } from './use-user'
export const useUsers = () => { export const useUsers = () => {
const [users, setUsers] = useState<User[]>([]) const [users, setUsers] = useState<User[]>([])
@ -59,8 +60,9 @@ export const useDiscoverUsers = (userId: string | null | undefined) => {
}) })
}, [userId]) }, [userId])
const followedUserIds = useFollows(userId) const user = useUser()
const nonSuggestions = [userId ?? '', ...(followedUserIds ?? [])] const followedUserIds = useFollows(user?.id)
const nonSuggestions = [user?.id ?? '', ...(followedUserIds ?? [])]
return difference(discoverUserIds, nonSuggestions).slice(0, 50) return difference(discoverUserIds, nonSuggestions).slice(0, 50)
} }