refactor: remove electron-related code
This commit is contained in:
parent
bed8df06e8
commit
2b1e6fe8f5
200 changed files with 2771 additions and 8432 deletions
54
src/pages/secondary/NoteListPage/index.tsx
Normal file
54
src/pages/secondary/NoteListPage/index.tsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import NoteList from '@/components/NoteList'
|
||||
import { useSearchParams } from '@/hooks'
|
||||
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { isWebsocketUrl } from '@/lib/url'
|
||||
import { useRelaySettings } from '@/providers/RelaySettingsProvider'
|
||||
import { Filter } from 'nostr-tools'
|
||||
import { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export default function NoteListPage() {
|
||||
const { t } = useTranslation()
|
||||
const { relayUrls, searchableRelayUrls } = useRelaySettings()
|
||||
const { searchParams } = useSearchParams()
|
||||
const relayUrlsString = JSON.stringify(relayUrls)
|
||||
const {
|
||||
title = '',
|
||||
filter,
|
||||
urls
|
||||
} = useMemo<{
|
||||
title?: string
|
||||
filter?: Filter
|
||||
urls: string[]
|
||||
}>(() => {
|
||||
const hashtag = searchParams.get('t')
|
||||
if (hashtag) {
|
||||
return { title: `# ${hashtag}`, filter: { '#t': [hashtag] }, urls: relayUrls }
|
||||
}
|
||||
const search = searchParams.get('s')
|
||||
if (search) {
|
||||
return { title: `${t('search')}: ${search}`, filter: { search }, urls: relayUrls }
|
||||
}
|
||||
const relayUrl = searchParams.get('relay')
|
||||
if (relayUrl && isWebsocketUrl(relayUrl)) {
|
||||
return { title: relayUrl, urls: [relayUrl] }
|
||||
}
|
||||
return { urls: relayUrls }
|
||||
}, [searchParams, relayUrlsString])
|
||||
|
||||
if (filter?.search && searchableRelayUrls.length === 0) {
|
||||
return (
|
||||
<SecondaryPageLayout titlebarContent={title}>
|
||||
<div className="text-center text-sm text-muted-foreground">
|
||||
{t('The relays you are connected to do not support search')}
|
||||
</div>
|
||||
</SecondaryPageLayout>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<SecondaryPageLayout titlebarContent={title}>
|
||||
<NoteList key={title} filter={filter} relayUrls={urls} />
|
||||
</SecondaryPageLayout>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue