refactor: search

This commit is contained in:
codytseng 2025-08-31 22:43:47 +08:00
parent 88567c2c13
commit 0153465e29
24 changed files with 785 additions and 345 deletions

View file

@ -0,0 +1,34 @@
import { BIG_RELAY_URLS, SEARCHABLE_RELAY_URLS } from '@/constants'
import { TSearchParams } from '@/types'
import NormalFeed from '../NormalFeed'
import Profile from '../Profile'
import { ProfileListBySearch } from '../ProfileListBySearch'
import Relay from '../Relay'
import TrendingNotes from '../TrendingNotes'
export default function SearchResult({ searchParams }: { searchParams: TSearchParams | null }) {
if (!searchParams) {
return <TrendingNotes />
}
if (searchParams.type === 'profile') {
return <Profile id={searchParams.search} />
}
if (searchParams.type === 'profiles') {
return <ProfileListBySearch search={searchParams.search} />
}
if (searchParams.type === 'notes') {
return (
<NormalFeed
subRequests={[{ urls: SEARCHABLE_RELAY_URLS, filter: { search: searchParams.search } }]}
/>
)
}
if (searchParams.type === 'hashtag') {
return (
<NormalFeed
subRequests={[{ urls: BIG_RELAY_URLS, filter: { '#t': [searchParams.search] } }]}
/>
)
}
return <Relay url={searchParams.search} />
}