Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client
117
fork

Configure Feed

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

[ALG-77] include 'for you' in see more suggested users (#10241)

authored by

Spence Pope and committed by
GitHub
8d3eba23 59a2d19c

+45 -24
+31 -16
src/components/ProgressGuide/FollowDialog.tsx
··· 109 109 let lastSelectedInterest = '' 110 110 let lastSearchText = '' 111 111 112 + const FOR_YOU_TAB = 'all' 113 + 112 114 function DialogInner({guide}: {guide?: Follow10ProgressGuide}) { 113 115 const {t: l} = useLingui() 114 116 const ax = useAnalytics() 115 - const interestsDisplayNames = useInterestsDisplayNames() 117 + const rawInterestsDisplayNames = useInterestsDisplayNames() 116 118 const {data: preferences} = usePreferencesQuery() 117 119 const personalizedInterests = preferences?.interests?.tags 118 - const interests = Object.keys(interestsDisplayNames) 119 - .sort(boostInterests(popularInterests)) 120 - .sort(boostInterests(personalizedInterests)) 120 + const interests = useMemo( 121 + () => [ 122 + FOR_YOU_TAB, 123 + ...Object.keys(rawInterestsDisplayNames) 124 + .sort(boostInterests(popularInterests)) 125 + .sort(boostInterests(personalizedInterests)), 126 + ], 127 + [rawInterestsDisplayNames, personalizedInterests], 128 + ) 129 + const interestsDisplayNames = useMemo( 130 + () => ({ 131 + [FOR_YOU_TAB]: l`For You`, 132 + ...rawInterestsDisplayNames, 133 + }), 134 + [l, rawInterestsDisplayNames], 135 + ) 121 136 const [selectedInterest, setSelectedInterest] = useState( 122 - () => 123 - lastSelectedInterest || 124 - (personalizedInterests && interests.includes(personalizedInterests[0]) 125 - ? personalizedInterests[0] 126 - : interests[0]), 137 + () => lastSelectedInterest || FOR_YOU_TAB, 127 138 ) 128 139 const [searchText, setSearchText] = useState(lastSearchText) 129 140 const moderationOpts = useModerationOpts() ··· 137 148 lastSelectedInterest = selectedInterest 138 149 }, [searchText, selectedInterest]) 139 150 140 - const { 141 - data: suggestions, 142 - isFetching: isFetchingSuggestions, 143 - error: suggestionsError, 144 - } = useGetSuggestedUsersForSeeMoreQuery({ 145 - category: selectedInterest, 151 + const isForYou = selectedInterest === FOR_YOU_TAB 152 + 153 + const seeMoreQuery = useGetSuggestedUsersForSeeMoreQuery({ 154 + category: isForYou ? undefined : selectedInterest, 146 155 limit: 50, 147 156 }) 157 + const suggestions = seeMoreQuery.data 158 + const isFetchingSuggestions = seeMoreQuery.isFetching 159 + const suggestionsError = seeMoreQuery.error 148 160 const { 149 161 data: searchResults, 150 162 isFetching: isFetchingSearchResults, ··· 277 289 recId: recIdForLogging, 278 290 position: position !== -1 ? position : 0, 279 291 suggestedDid: item.profile.did, 280 - category: selectedInterestRef.current, 292 + category: 293 + selectedInterestRef.current === FOR_YOU_TAB 294 + ? null 295 + : selectedInterestRef.current, 281 296 }) 282 297 } 283 298 }
+4 -4
src/state/queries/trending/useGetSuggestedUsersForDiscoverQuery.ts
··· 19 19 20 20 export const getSuggestedUsersForDiscoverQueryKeyRoot = 21 21 'unspecced-suggested-users-for-explore' 22 - export const createGetSuggestedUsersForDiscoverQueryKey = ( 23 - props: QueryProps, 24 - ) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit] 22 + export const createGetSuggestedUsersForDiscoverQueryKey = (props: { 23 + limit?: number 24 + }) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit] 25 25 26 26 export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) { 27 27 const agent = useAgent() ··· 29 29 30 30 return useQuery({ 31 31 staleTime: STALE.MINUTES.THREE, 32 - queryKey: createGetSuggestedUsersForDiscoverQueryKey(props), 32 + queryKey: createGetSuggestedUsersForDiscoverQueryKey({limit: props.limit}), 33 33 queryFn: async () => { 34 34 const contentLangs = getContentLanguages().join(',') 35 35 const userInterests = aggregateUserInterests(preferences)
+10 -4
src/state/queries/trending/useGetSuggestedUsersForSeeMoreQuery.ts
··· 16 16 export type QueryProps = { 17 17 category?: string | null 18 18 limit?: number 19 + enabled?: boolean 19 20 } 20 21 21 22 export const getSuggestedUsersForSeeMoreQueryKeyRoot = 22 23 'unspecced-suggested-users-for-explore' 23 - export const createGetSuggestedUsersForSeeMoreQueryKey = ( 24 - props: QueryProps, 25 - ) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit] 24 + export const createGetSuggestedUsersForSeeMoreQueryKey = (props: { 25 + category?: string | null 26 + limit?: number 27 + }) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit] 26 28 27 29 export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) { 28 30 const agent = useAgent() 29 31 const {data: preferences} = usePreferencesQuery() 30 32 31 33 return useQuery({ 34 + enabled: props.enabled ?? true, 32 35 staleTime: STALE.MINUTES.THREE, 33 - queryKey: createGetSuggestedUsersForSeeMoreQueryKey(props), 36 + queryKey: createGetSuggestedUsersForSeeMoreQueryKey({ 37 + category: props.category, 38 + limit: props.limit, 39 + }), 34 40 queryFn: async () => { 35 41 const contentLangs = getContentLanguages().join(',') 36 42 const userInterests = aggregateUserInterests(preferences)