diff options
author | dan <dan.abramov@gmail.com> | 2024-04-24 17:45:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 17:45:11 +0100 |
commit | e2a59449dfc5da9c06b98ad66b3669fff67f9506 (patch) | |
tree | 88764fd7839e3a1e96b66eec084468d7a40258ac /src/view | |
parent | 8ec3d8c76e4ec94628ecb8b85eab1cbf83dcefe1 (diff) | |
download | voidsky-e2a59449dfc5da9c06b98ad66b3669fff67f9506.tar.zst |
Remove old Suggested Follows logic (#3689)
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/screens/Search/Search.tsx | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index 099174b9b..2cc0766d2 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -22,7 +22,6 @@ import {HITSLOP_10} from '#/lib/constants' import {usePalette} from '#/lib/hooks/usePalette' import {MagnifyingGlassIcon} from '#/lib/icons' import {NavigationProp} from '#/lib/routes/types' -import {useGate} from '#/lib/statsig/statsig' import {augmentSearchQuery} from '#/lib/strings/helpers' import {s} from '#/lib/styles' import {logger} from '#/logger' @@ -32,10 +31,7 @@ import {useActorAutocompleteFn} from '#/state/queries/actor-autocomplete' import {useActorSearch} from '#/state/queries/actor-search' import {useModerationOpts} from '#/state/queries/preferences' import {useSearchPostsQuery} from '#/state/queries/search-posts' -import { - useGetSuggestedFollowersByActor, - useSuggestedFollowsQuery, -} from '#/state/queries/suggested-follows' +import {useSuggestedFollowsQuery} from '#/state/queries/suggested-follows' import {useSession} from '#/state/session' import {useSetDrawerOpen} from '#/state/shell' import {useSetDrawerSwipeDisabled, useSetMinimalShellMode} from '#/state/shell' @@ -121,56 +117,7 @@ function EmptyState({message, error}: {message: string; error?: string}) { ) } -function useSuggestedFollowsV1(): [ - AppBskyActorDefs.ProfileViewBasic[], - () => void, -] { - const {currentAccount} = useSession() - const [suggestions, setSuggestions] = React.useState< - AppBskyActorDefs.ProfileViewBasic[] - >([]) - const getSuggestedFollowsByActor = useGetSuggestedFollowersByActor() - - React.useEffect(() => { - async function getSuggestions() { - const friends = await getSuggestedFollowsByActor( - currentAccount!.did, - ).then(friendsRes => friendsRes.suggestions) - - if (!friends) return // :( - - const friendsOfFriends = new Map< - string, - AppBskyActorDefs.ProfileViewBasic - >() - - await Promise.all( - friends.slice(0, 4).map(friend => - getSuggestedFollowsByActor(friend.did).then(foafsRes => { - for (const user of foafsRes.suggestions) { - if (user.associated?.labeler) continue - friendsOfFriends.set(user.did, user) - } - }), - ), - ) - - setSuggestions(Array.from(friendsOfFriends.values())) - } - - try { - getSuggestions() - } catch (e) { - logger.error(`SearchScreenSuggestedFollows: failed to get suggestions`, { - message: e, - }) - } - }, [currentAccount, setSuggestions, getSuggestedFollowsByActor]) - - return [suggestions, () => {}] -} - -function useSuggestedFollowsV2(): [ +function useSuggestedFollows(): [ AppBskyActorDefs.ProfileViewBasic[], () => void, ] { @@ -210,12 +157,6 @@ function useSuggestedFollowsV2(): [ function SearchScreenSuggestedFollows() { const pal = usePalette('default') - const gate = useGate() - const useSuggestedFollows = gate('use_new_suggestions_endpoint') - ? // Conditional hook call here is *only* OK because useGate() - // result won't change until a remount. - useSuggestedFollowsV2 - : useSuggestedFollowsV1 const [suggestions, onEndReached] = useSuggestedFollows() return suggestions.length ? ( |