Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove old Suggested Follows logic (#3689)

authored by

dan and committed by
GitHub
e2a59449 8ec3d8c7

+2 -87
-1
src/lib/statsig/gates.ts
··· 8 8 | 'start_session_with_following_v2' 9 9 | 'test_gate_1' 10 10 | 'test_gate_2' 11 - | 'use_new_suggestions_endpoint'
-25
src/state/queries/suggested-follows.ts
··· 1 - import React from 'react' 2 1 import { 3 2 AppBskyActorDefs, 4 3 AppBskyActorGetSuggestions, ··· 11 10 QueryKey, 12 11 useInfiniteQuery, 13 12 useQuery, 14 - useQueryClient, 15 13 } from '@tanstack/react-query' 16 14 17 15 import {STALE} from '#/state/queries' ··· 88 86 return res.data 89 87 }, 90 88 }) 91 - } 92 - 93 - export function useGetSuggestedFollowersByActor() { 94 - const queryClient = useQueryClient() 95 - 96 - return React.useCallback( 97 - async (actor: string) => { 98 - const res = await queryClient.fetchQuery({ 99 - staleTime: STALE.MINUTES.ONE, 100 - queryKey: suggestedFollowsByActorQueryKey(actor), 101 - queryFn: async () => { 102 - const res = 103 - await getAgent().app.bsky.graph.getSuggestedFollowsByActor({ 104 - actor: actor, 105 - }) 106 - return res.data 107 - }, 108 - }) 109 - 110 - return res 111 - }, 112 - [queryClient], 113 - ) 114 89 } 115 90 116 91 export function* findAllProfilesInQueryData(
+2 -61
src/view/screens/Search/Search.tsx
··· 22 22 import {usePalette} from '#/lib/hooks/usePalette' 23 23 import {MagnifyingGlassIcon} from '#/lib/icons' 24 24 import {NavigationProp} from '#/lib/routes/types' 25 - import {useGate} from '#/lib/statsig/statsig' 26 25 import {augmentSearchQuery} from '#/lib/strings/helpers' 27 26 import {s} from '#/lib/styles' 28 27 import {logger} from '#/logger' ··· 32 31 import {useActorSearch} from '#/state/queries/actor-search' 33 32 import {useModerationOpts} from '#/state/queries/preferences' 34 33 import {useSearchPostsQuery} from '#/state/queries/search-posts' 35 - import { 36 - useGetSuggestedFollowersByActor, 37 - useSuggestedFollowsQuery, 38 - } from '#/state/queries/suggested-follows' 34 + import {useSuggestedFollowsQuery} from '#/state/queries/suggested-follows' 39 35 import {useSession} from '#/state/session' 40 36 import {useSetDrawerOpen} from '#/state/shell' 41 37 import {useSetDrawerSwipeDisabled, useSetMinimalShellMode} from '#/state/shell' ··· 121 117 ) 122 118 } 123 119 124 - function useSuggestedFollowsV1(): [ 125 - AppBskyActorDefs.ProfileViewBasic[], 126 - () => void, 127 - ] { 128 - const {currentAccount} = useSession() 129 - const [suggestions, setSuggestions] = React.useState< 130 - AppBskyActorDefs.ProfileViewBasic[] 131 - >([]) 132 - const getSuggestedFollowsByActor = useGetSuggestedFollowersByActor() 133 - 134 - React.useEffect(() => { 135 - async function getSuggestions() { 136 - const friends = await getSuggestedFollowsByActor( 137 - currentAccount!.did, 138 - ).then(friendsRes => friendsRes.suggestions) 139 - 140 - if (!friends) return // :( 141 - 142 - const friendsOfFriends = new Map< 143 - string, 144 - AppBskyActorDefs.ProfileViewBasic 145 - >() 146 - 147 - await Promise.all( 148 - friends.slice(0, 4).map(friend => 149 - getSuggestedFollowsByActor(friend.did).then(foafsRes => { 150 - for (const user of foafsRes.suggestions) { 151 - if (user.associated?.labeler) continue 152 - friendsOfFriends.set(user.did, user) 153 - } 154 - }), 155 - ), 156 - ) 157 - 158 - setSuggestions(Array.from(friendsOfFriends.values())) 159 - } 160 - 161 - try { 162 - getSuggestions() 163 - } catch (e) { 164 - logger.error(`SearchScreenSuggestedFollows: failed to get suggestions`, { 165 - message: e, 166 - }) 167 - } 168 - }, [currentAccount, setSuggestions, getSuggestedFollowsByActor]) 169 - 170 - return [suggestions, () => {}] 171 - } 172 - 173 - function useSuggestedFollowsV2(): [ 120 + function useSuggestedFollows(): [ 174 121 AppBskyActorDefs.ProfileViewBasic[], 175 122 () => void, 176 123 ] { ··· 210 157 211 158 function SearchScreenSuggestedFollows() { 212 159 const pal = usePalette('default') 213 - const gate = useGate() 214 - const useSuggestedFollows = gate('use_new_suggestions_endpoint') 215 - ? // Conditional hook call here is *only* OK because useGate() 216 - // result won't change until a remount. 217 - useSuggestedFollowsV2 218 - : useSuggestedFollowsV1 219 160 const [suggestions, onEndReached] = useSuggestedFollows() 220 161 221 162 return suggestions.length ? (