Bluesky app fork with some witchin' additions 💫

Fix string concat bug with trending topics muteword moderation (#9914)

authored by samuel.fm and committed by

GitHub 35f9ed82 8c4fc087

+6 -6
+6 -6
src/state/queries/trending/useTrendingTopics.ts
··· 1 - import React from 'react' 1 + import {useCallback, useMemo} from 'react' 2 2 import {type AppBskyUnspeccedDefs, hasMutedWord} from '@atproto/api' 3 3 import {useQuery} from '@tanstack/react-query' 4 4 ··· 29 29 export function useTrendingTopics() { 30 30 const agent = useAgent() 31 31 const {data: preferences} = usePreferencesQuery() 32 - const mutedWords = React.useMemo( 32 + const mutedWords = useMemo( 33 33 () => preferences?.moderationPrefs?.mutedWords ?? [], 34 34 [preferences?.moderationPrefs?.mutedWords], 35 35 ) ··· 39 39 staleTime: STALE.MINUTES.THREE, 40 40 queryKey: trendingTopicsQueryKey, 41 41 async queryFn() { 42 - const {data} = await agent.api.app.bsky.unspecced.getTrendingTopics({ 42 + const {data} = await agent.app.bsky.unspecced.getTrendingTopics({ 43 43 limit: DEFAULT_LIMIT, 44 44 }) 45 45 return { ··· 47 47 suggested: data.suggested ?? [], 48 48 } 49 49 }, 50 - select: React.useCallback( 50 + select: useCallback( 51 51 (data: Response) => { 52 52 return { 53 53 topics: dedup( 54 54 data.topics.filter(t => { 55 55 return !hasMutedWord({ 56 56 mutedWords, 57 - text: t.topic + ' ' + t.displayName + ' ' + t.description, 57 + text: `${t.topic} ${t.displayName ?? ''} ${t.description ?? ''}`, 58 58 }) 59 59 }), 60 60 ), ··· 62 62 data.suggested.filter(t => { 63 63 return !hasMutedWord({ 64 64 mutedWords, 65 - text: t.topic + ' ' + t.displayName + ' ' + t.description, 65 + text: `${t.topic} ${t.displayName ?? ''} ${t.description ?? ''}`, 66 66 }) 67 67 }), 68 68 ),