refactor: search
This commit is contained in:
parent
88567c2c13
commit
0153465e29
24 changed files with 785 additions and 345 deletions
34
src/components/SearchResult/index.tsx
Normal file
34
src/components/SearchResult/index.tsx
Normal 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} />
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue