[Explore] Moderate trending topic avis (#8123)
* moderate trending topic avis * filter blurs too
This commit is contained in:
@@ -6,7 +6,7 @@ import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
|||||||
import {useProfilesQuery} from '#/state/queries/profile'
|
import {useProfilesQuery} from '#/state/queries/profile'
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function AvatarStack({
|
export function AvatarStack({
|
||||||
profiles,
|
profiles,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import {useMemo} from 'react'
|
||||||
import {Pressable, View} from 'react-native'
|
import {Pressable, View} from 'react-native'
|
||||||
import {type AppBskyUnspeccedDefs} from '@atproto/api'
|
import {type AppBskyUnspeccedDefs, moderateProfile} from '@atproto/api'
|
||||||
import {msg, plural, Trans} from '@lingui/macro'
|
import {msg, plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useTrendingSettings} from '#/state/preferences/trending'
|
import {useTrendingSettings} from '#/state/preferences/trending'
|
||||||
import {useGetTrendsQuery} from '#/state/queries/trending/useGetTrendsQuery'
|
import {useGetTrendsQuery} from '#/state/queries/trending/useGetTrendsQuery'
|
||||||
import {useTrendingConfig} from '#/state/trending-config'
|
import {useTrendingConfig} from '#/state/trending-config'
|
||||||
@@ -78,6 +80,8 @@ export function TrendRow({
|
|||||||
)
|
)
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
const actors = useModerateTrendingActors(trend.actors)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
testID={trend.link}
|
testID={trend.link}
|
||||||
@@ -118,8 +122,8 @@ export function TrendRow({
|
|||||||
a.align_center,
|
a.align_center,
|
||||||
{paddingLeft: 20},
|
{paddingLeft: 20},
|
||||||
]}>
|
]}>
|
||||||
{trend.actors.length > 0 && (
|
{actors.length > 0 && (
|
||||||
<AvatarStack size={20} profiles={trend.actors} />
|
<AvatarStack size={20} profiles={actors} />
|
||||||
)}
|
)}
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
@@ -276,3 +280,20 @@ export function TrendingTopicRowSkeleton({}: {withPosts: boolean}) {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useModerateTrendingActors(
|
||||||
|
actors: AppBskyUnspeccedDefs.TrendView['actors'],
|
||||||
|
) {
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
|
return useMemo(() => {
|
||||||
|
if (!moderationOpts) return []
|
||||||
|
|
||||||
|
return actors
|
||||||
|
.filter(actor => {
|
||||||
|
const decision = moderateProfile(actor, moderationOpts)
|
||||||
|
return !decision.ui('avatar').filter && !decision.ui('avatar').blur
|
||||||
|
})
|
||||||
|
.slice(0, 3)
|
||||||
|
}, [actors, moderationOpts])
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user