Filter out imperative labels from typeaheads
This commit is contained in:
@@ -33,6 +33,14 @@ export function isJustAMute(modui: ModerationUI): boolean {
|
||||
return modui.filters.length === 1 && modui.filters[0].type === 'muted'
|
||||
}
|
||||
|
||||
export function isImperative(modui: ModerationUI): boolean {
|
||||
const label = modui.filters.at(0)
|
||||
if (label && label.type === 'label') {
|
||||
return ['!hide', '!takedown'].includes(label.label.val)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function getLabelingServiceTitle({
|
||||
displayName,
|
||||
handle,
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
||||
import {keepPreviousData, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {isJustAMute} from '#/lib/moderation'
|
||||
import {isImperative, isJustAMute} from '#/lib/moderation'
|
||||
import {logger} from '#/logger'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {useAgent} from '#/state/session'
|
||||
@@ -113,6 +113,10 @@ function computeSuggestions({
|
||||
return items.filter(profile => {
|
||||
const modui = moderateProfile(profile, moderationOpts).ui('profileList')
|
||||
const isExactMatch = q && profile.handle.toLowerCase() === q
|
||||
return isExactMatch || !modui.filter || isJustAMute(modui)
|
||||
return (
|
||||
(isExactMatch && !isImperative(modui)) ||
|
||||
!modui.filter ||
|
||||
isJustAMute(modui)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user