Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Improve dedupe logic on search suggestions (#1958)

authored by

Eric Bailey and committed by
GitHub
019aae5f 7c51a393

+14 -15
+14 -15
src/view/screens/Search/Search.tsx
··· 119 119 120 120 React.useEffect(() => { 121 121 async function getSuggestions() { 122 - // TODO not quite right, doesn't fetch your follows 123 122 const friends = await getSuggestedFollowsByActor( 124 123 currentAccount!.did, 125 124 ).then(friendsRes => friendsRes.suggestions) 126 125 127 126 if (!friends) return // :( 128 127 129 - const friendsOfFriends = ( 130 - await Promise.all( 131 - friends 132 - .slice(0, 4) 133 - .map(friend => 134 - getSuggestedFollowsByActor(friend.did).then( 135 - foafsRes => foafsRes.suggestions, 136 - ), 137 - ), 138 - ) 139 - ).flat() 140 - const deduped = friendsOfFriends.filter( 141 - (f, i) => friendsOfFriends.findIndex(f2 => f.did === f2.did) === i, 128 + const friendsOfFriends = new Map< 129 + string, 130 + AppBskyActorDefs.ProfileViewBasic 131 + >() 132 + 133 + await Promise.all( 134 + friends.slice(0, 4).map(friend => 135 + getSuggestedFollowsByActor(friend.did).then(foafsRes => { 136 + for (const user of foafsRes.suggestions) { 137 + friendsOfFriends.set(user.did, user) 138 + } 139 + }), 140 + ), 142 141 ) 143 142 144 - setSuggestions(deduped) 143 + setSuggestions(Array.from(friendsOfFriends.values())) 145 144 setDataUpdatedAt(Date.now()) 146 145 } 147 146