diff --git a/src/components/DisplaySigit/index.tsx b/src/components/DisplaySigit/index.tsx
index 5147b45..20550b3 100644
--- a/src/components/DisplaySigit/index.tsx
+++ b/src/components/DisplaySigit/index.tsx
@@ -112,32 +112,37 @@ export const DisplaySigit = ({
>
)}
-
-
-
-
-
-
-
-
+ {
+ // TODO: enable buttons once feature is ready
+ false && (
+
+
+
+
+
+
+
+
+ )
+ }
)
}
diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx
index 89a09b4..4501ecc 100644
--- a/src/pages/create/index.tsx
+++ b/src/pages/create/index.tsx
@@ -46,7 +46,8 @@ import {
DEFAULT_TOOLBOX,
settleAllFullfilfedPromises,
parseNostrEvent,
- uploadMetaToFileStorage
+ uploadMetaToFileStorage,
+ timeout
} from '../../utils'
import { Container } from '../../components/Container'
import fileListStyles from '../../components/FileList/style.module.scss'
@@ -81,6 +82,7 @@ import { useNDKContext } from '../../hooks/useNDKContext.ts'
import { useNDK } from '../../hooks/useNDK.ts'
import { useImmer } from 'use-immer'
import { ButtonUnderline } from '../../components/ButtonUnderline/index.tsx'
+import { TimeoutError } from '../../types/errors/TimeoutError.ts'
type FoundUser = NostrEvent & { npub: string }
@@ -165,8 +167,8 @@ export const CreatePage = () => {
return pubkey
}
- const handleSearchUsers = async (searchValue?: string) => {
- const searchString = searchValue || userSearchInput || undefined
+ const handleSearchUsers = async () => {
+ const searchString = userSearchInput || undefined
if (!searchString) return
@@ -174,14 +176,17 @@ export const CreatePage = () => {
const searchTerm = searchString.trim()
- fetchEventsFromUserRelays(
- {
- kinds: [0],
- search: searchTerm
- },
- usersPubkey,
- UserRelaysType.Write
- )
+ Promise.race([
+ fetchEventsFromUserRelays(
+ {
+ kinds: [0],
+ search: searchTerm
+ },
+ usersPubkey,
+ UserRelaysType.Write
+ ),
+ timeout(30000)
+ ])
.then((events) => {
const nostrEvents = events.map((event) => event.rawEvent())
@@ -219,6 +224,9 @@ export const CreatePage = () => {
toast.info('No user found with the provided search term')
})
.catch((error) => {
+ if (error instanceof TimeoutError) {
+ toast.error('Search timed out. Please try again.')
+ }
console.error(error)
})
.finally(() => {
@@ -248,22 +256,23 @@ export const CreatePage = () => {
// If pasted user npub of nip05 is present, we just add the user to the counterparts list
if (pastedUserNpubOrNip05) {
- setUserInput(pastedUserNpubOrNip05)
+ setUserInput(pastedUserNpubOrNip05.trim())
setPastedUserNpubOrNip05(undefined)
} else {
- // Otherwize if search already provided some results, user must manually click the search button
+ // Otherwise if search already provided some results, user must manually click the search button
if (!foundUsers.length) {
+ const searchTerm = userSearchInput.trim()
// If it's NIP05 (includes @ or is a valid domain) send request to .well-known
const domainRegex = /^[a-zA-Z0-9@.-]+\.[a-zA-Z]{2,}$/
- if (domainRegex.test(userSearchInput)) {
+ if (searchTerm.startsWith('_@') || domainRegex.test(searchTerm)) {
setSearchUsersLoading(true)
- const pubkey = await handleSearchUserNip05(userSearchInput)
+ const pubkey = await handleSearchUserNip05(searchTerm)
setSearchUsersLoading(false)
if (pubkey) {
- setUserInput(userSearchInput)
+ setUserInput(searchTerm)
} else {
toast.error(`No user found with the NIP05: ${userSearchInput}`)
}
@@ -414,7 +423,7 @@ export const CreatePage = () => {
setUserSearchInput('')
- if (input.startsWith('npub')) {
+ if (input.startsWith('npub1')) {
return handleAddNpubUser(input)
}
@@ -1059,17 +1068,13 @@ export const CreatePage = () => {
}
// Seems like it's npub format
- if (value.startsWith('npub')) {
- // We will try to convert npub to hex and if it's successfull that means
- // npub is valid
- const validHexPubkey = npubToHex(value)
-
- if (validHexPubkey) {
- // Arm the manual user npub add after enter is hit, we don't want to trigger search
- setPastedUserNpubOrNip05(value)
- } else {
- disarmAddOnEnter()
- }
+ if (value.trim().startsWith('npub1')) {
+ setPastedUserNpubOrNip05(value.trim())
+ } else if (value.trim().startsWith('nsec1')) {
+ toast.warn('Oops - never paste your nsec into a website! Key deleted.')
+ if (searchFieldRef.current) searchFieldRef.current.value = ''
+ setUserSearchInput('')
+ return
} else {
// Disarm the add user on enter hit, and trigger search after 1 second
disarmAddOnEnter()
@@ -1229,7 +1234,7 @@ export const CreatePage = () => {
{!pastedUserNpubOrNip05 ? (