Invalid handle autocomplete (#2251)

* refactor invalid handle check from a previous PR to use util function

* add invalid handle check to `prefixMatch`
This commit is contained in:
Samuel Newman 2023-12-20 17:50:50 +00:00 committed by GitHub
parent 946b2c9163
commit 4a93a5b6ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import {
getModerationOpts, getModerationOpts,
useModerationOpts, useModerationOpts,
} from './preferences' } from './preferences'
import {isInvalidHandle} from '#/lib/strings/handles'
const DEFAULT_MOD_OPTS = getModerationOpts({ const DEFAULT_MOD_OPTS = getModerationOpts({
userDid: '', userDid: '',
@ -119,7 +120,7 @@ function prefixMatch(
prefix: string, prefix: string,
info: AppBskyActorDefs.ProfileViewBasic, info: AppBskyActorDefs.ProfileViewBasic,
): boolean { ): boolean {
if (info.handle.includes(prefix)) { if (!isInvalidHandle(info.handle) && info.handle.includes(prefix)) {
return true return true
} }
if (info.displayName?.toLocaleLowerCase().includes(prefix)) { if (info.displayName?.toLocaleLowerCase().includes(prefix)) {

View file

@ -39,6 +39,7 @@ import {truncateAndInvalidate} from '#/state/queries/util'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {isInvalidHandle} from '#/lib/strings/handles'
interface SectionRef { interface SectionRef {
scrollToTop: () => void scrollToTop: () => void
@ -231,7 +232,7 @@ function ProfileScreenLoaded({
track('ProfileScreen:PressCompose') track('ProfileScreen:PressCompose')
const mention = const mention =
profile.handle === currentAccount?.handle || profile.handle === currentAccount?.handle ||
profile.handle === 'handle.invalid' isInvalidHandle(profile.handle)
? undefined ? undefined
: profile.handle : profile.handle
openComposer({mention}) openComposer({mention})

View file

@ -46,6 +46,7 @@ import {useComposerControls} from '#/state/shell/composer'
import {useFetchHandle} from '#/state/queries/handle' import {useFetchHandle} from '#/state/queries/handle'
import {emitSoftReset} from '#/state/events' import {emitSoftReset} from '#/state/events'
import {NavSignupCard} from '#/view/shell/NavSignupCard' import {NavSignupCard} from '#/view/shell/NavSignupCard'
import {isInvalidHandle} from '#/lib/strings/handles'
function ProfileCard() { function ProfileCard() {
const {currentAccount} = useSession() const {currentAccount} = useSession()
@ -221,7 +222,7 @@ function ComposeBtn() {
if ( if (
!handle || !handle ||
handle === currentAccount?.handle || handle === currentAccount?.handle ||
handle === 'handle.invalid' isInvalidHandle(handle)
) )
return undefined return undefined