fix: counterpart search NIP05 glitching
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 44s
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 44s
This commit is contained in:
parent
69efd9e09d
commit
0fd0f26fc7
@ -148,6 +148,17 @@ export const CreatePage = () => {
|
||||
[setUserInput]
|
||||
)
|
||||
|
||||
const handleSearchUserNip05 = async (
|
||||
nip05: string
|
||||
): Promise<string | null> => {
|
||||
const { pubkey } = await queryNip05(nip05).catch((err) => {
|
||||
console.error(err)
|
||||
return { pubkey: null }
|
||||
})
|
||||
|
||||
return pubkey
|
||||
}
|
||||
|
||||
const handleSearchUsers = async (searchValue?: string) => {
|
||||
const searchString = searchValue || userSearchInput || undefined
|
||||
|
||||
@ -224,7 +235,9 @@ export const CreatePage = () => {
|
||||
})
|
||||
}, [foundUsers])
|
||||
|
||||
const handleInputKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
const handleInputKeyDown = async (
|
||||
event: React.KeyboardEvent<HTMLDivElement>
|
||||
) => {
|
||||
if (
|
||||
event.code === KeyboardCode.Enter ||
|
||||
event.code === KeyboardCode.NumpadEnter
|
||||
@ -238,7 +251,18 @@ export const CreatePage = () => {
|
||||
} else {
|
||||
// Otherwize if search already provided some results, user must manually click the search button
|
||||
if (!foundUsers.length) {
|
||||
handleSearchUsers()
|
||||
// If it's NIP05 send request to .well-known
|
||||
if (userSearchInput.includes('@')) {
|
||||
const pubkey = await handleSearchUserNip05(userSearchInput)
|
||||
|
||||
if (pubkey) {
|
||||
setUserInput(userSearchInput)
|
||||
} else {
|
||||
toast.error(`No user found with the NIP05: ${userSearchInput}`)
|
||||
}
|
||||
} else {
|
||||
handleSearchUsers()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -959,19 +983,6 @@ export const CreatePage = () => {
|
||||
} else {
|
||||
disarmAddOnEnter()
|
||||
}
|
||||
} else if (value.includes('@')) {
|
||||
// Seems like it's nip05 format
|
||||
const { pubkey } = await queryNip05(value).catch((err) => {
|
||||
console.error(err)
|
||||
return { pubkey: null }
|
||||
})
|
||||
|
||||
if (pubkey) {
|
||||
// Arm the manual user npub add after enter is hit, we don't want to trigger search
|
||||
setPastedUserNpubOrNip05(hexToNpub(pubkey))
|
||||
} else {
|
||||
disarmAddOnEnter()
|
||||
}
|
||||
} else {
|
||||
// Disarm the add user on enter hit, and trigger search after 1 second
|
||||
disarmAddOnEnter()
|
||||
|
Loading…
Reference in New Issue
Block a user