From 7be7b30d525245dbaa665fc90538724bcb8b81f4 Mon Sep 17 00:00:00 2001 From: codytseng Date: Thu, 12 Mar 2026 22:25:29 +0800 Subject: [PATCH] fix: skip fayan search when input is a hex ID or bech32 ID Co-Authored-By: Claude Opus 4.6 --- src/components/SearchBar/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/SearchBar/index.tsx b/src/components/SearchBar/index.tsx index 2540513..8ac6f1b 100644 --- a/src/components/SearchBar/index.tsx +++ b/src/components/SearchBar/index.tsx @@ -36,7 +36,17 @@ const SearchBar = forwardRef< const { push } = useSecondaryPage() const { isSmallScreen } = useScreenSize() const [debouncedInput, setDebouncedInput] = useState(input) - const { profiles, isFetching: isFetchingProfiles } = useSearchProfiles(debouncedInput, 5) + const isIdSearch = useMemo(() => { + const search = debouncedInput.trim() + if (!search) return false + if (/^[0-9a-f]{64}$/.test(search)) return true + const id = search.startsWith('nostr:') ? search.slice(6) : search + return /^(npub1|nprofile1|note1|nevent1|naddr1)/.test(id) + }, [debouncedInput]) + const { profiles, isFetching: isFetchingProfiles } = useSearchProfiles( + isIdSearch ? '' : debouncedInput, + 5 + ) const [searching, setSearching] = useState(false) const [displayList, setDisplayList] = useState(false) const [selectableOptions, setSelectableOptions] = useState([])