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