Bluesky app fork with some witchin' additions 💫

Fix mute words in trending (#7293)

authored by

Eric Bailey and committed by
GitHub
8b7a3318 d27ed321

+27 -15
+27 -15
src/state/queries/trending/useTrendingTopics.ts
··· 9 10 export type TrendingTopic = AppBskyUnspeccedDefs.TrendingTopic 11 12 export const DEFAULT_LIMIT = 14 13 14 export const trendingTopicsQueryKey = ['trending-topics'] ··· 20 return preferences?.moderationPrefs?.mutedWords || [] 21 }, [preferences?.moderationPrefs]) 22 23 - return useQuery({ 24 refetchOnWindowFocus: true, 25 staleTime: STALE.MINUTES.THREE, 26 queryKey: trendingTopicsQueryKey, ··· 28 const {data} = await agent.api.app.bsky.unspecced.getTrendingTopics({ 29 limit: DEFAULT_LIMIT, 30 }) 31 - 32 - const {topics, suggested} = data 33 return { 34 - topics: topics.filter(t => { 35 - return !hasMutedWord({ 36 - mutedWords, 37 - text: t.topic + ' ' + t.displayName + ' ' + t.description, 38 - }) 39 - }), 40 - suggested: suggested.filter(t => { 41 - return !hasMutedWord({ 42 - mutedWords, 43 - text: t.topic + ' ' + t.displayName + ' ' + t.description, 44 - }) 45 - }), 46 } 47 }, 48 }) 49 }
··· 9 10 export type TrendingTopic = AppBskyUnspeccedDefs.TrendingTopic 11 12 + type Response = { 13 + topics: TrendingTopic[] 14 + suggested: TrendingTopic[] 15 + } 16 + 17 export const DEFAULT_LIMIT = 14 18 19 export const trendingTopicsQueryKey = ['trending-topics'] ··· 25 return preferences?.moderationPrefs?.mutedWords || [] 26 }, [preferences?.moderationPrefs]) 27 28 + return useQuery<Response>({ 29 refetchOnWindowFocus: true, 30 staleTime: STALE.MINUTES.THREE, 31 queryKey: trendingTopicsQueryKey, ··· 33 const {data} = await agent.api.app.bsky.unspecced.getTrendingTopics({ 34 limit: DEFAULT_LIMIT, 35 }) 36 return { 37 + topics: data.topics ?? [], 38 + suggested: data.suggested ?? [], 39 } 40 }, 41 + select: React.useCallback( 42 + (data: Response) => { 43 + return { 44 + topics: data.topics.filter(t => { 45 + return !hasMutedWord({ 46 + mutedWords, 47 + text: t.topic + ' ' + t.displayName + ' ' + t.description, 48 + }) 49 + }), 50 + suggested: data.suggested.filter(t => { 51 + return !hasMutedWord({ 52 + mutedWords, 53 + text: t.topic + ' ' + t.displayName + ' ' + t.description, 54 + }) 55 + }), 56 + } 57 + }, 58 + [mutedWords], 59 + ), 60 }) 61 }