feat: add relay selector for posting
This commit is contained in:
parent
2439150c6e
commit
ec11d53fac
25 changed files with 418 additions and 201 deletions
|
|
@ -3,17 +3,28 @@ import RelayInfo from '@/components/RelayInfo'
|
|||
import SearchInput from '@/components/SearchInput'
|
||||
import { useFetchRelayInfo } from '@/hooks'
|
||||
import { normalizeUrl } from '@/lib/url'
|
||||
import { useCurrentRelays } from '@/providers/CurrentRelaysProvider'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import NotFound from '../NotFound'
|
||||
|
||||
export default function Relay({ url, className }: { url?: string; className?: string }) {
|
||||
const { t } = useTranslation()
|
||||
const { addRelayUrls, removeRelayUrls } = useCurrentRelays()
|
||||
const normalizedUrl = useMemo(() => (url ? normalizeUrl(url) : undefined), [url])
|
||||
const { relayInfo } = useFetchRelayInfo(normalizedUrl)
|
||||
const [searchInput, setSearchInput] = useState('')
|
||||
const [debouncedInput, setDebouncedInput] = useState(searchInput)
|
||||
|
||||
useEffect(() => {
|
||||
if (normalizedUrl) {
|
||||
addRelayUrls([normalizedUrl])
|
||||
return () => {
|
||||
removeRelayUrls([normalizedUrl])
|
||||
}
|
||||
}
|
||||
}, [normalizedUrl])
|
||||
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedInput(searchInput)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue