feat: sync relay sets
This commit is contained in:
parent
4343765aba
commit
7bd5b915eb
38 changed files with 1069 additions and 686 deletions
|
|
@ -1,16 +1,17 @@
|
|||
import NoteList from '@/components/NoteList'
|
||||
import { SEARCHABLE_RELAY_URLS } from '@/constants'
|
||||
import { useSearchParams } from '@/hooks'
|
||||
import { useFetchRelayInfos, useSearchParams } from '@/hooks'
|
||||
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { isWebsocketUrl, simplifyUrl } from '@/lib/url'
|
||||
import { useRelaySettings } from '@/providers/RelaySettingsProvider'
|
||||
import { useFeed } from '@/providers/FeedProvider'
|
||||
import { Filter } from 'nostr-tools'
|
||||
import { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export default function NoteListPage({ index }: { index?: number }) {
|
||||
const { t } = useTranslation()
|
||||
const { relayUrls, searchableRelayUrls } = useRelaySettings()
|
||||
const { relayUrls } = useFeed()
|
||||
const { searchableRelayUrls } = useFetchRelayInfos(relayUrls)
|
||||
const { searchParams } = useSearchParams()
|
||||
const relayUrlsString = JSON.stringify(relayUrls)
|
||||
const {
|
||||
|
|
@ -31,10 +32,7 @@ export default function NoteListPage({ index }: { index?: number }) {
|
|||
return {
|
||||
title: `${t('Search')}: ${search}`,
|
||||
filter: { search },
|
||||
urls:
|
||||
searchableRelayUrls.length < 4
|
||||
? searchableRelayUrls.concat(SEARCHABLE_RELAY_URLS).slice(0, 4)
|
||||
: searchableRelayUrls
|
||||
urls: searchableRelayUrls.concat(SEARCHABLE_RELAY_URLS).slice(0, 4)
|
||||
}
|
||||
}
|
||||
const relayUrl = searchParams.get('relay')
|
||||
|
|
@ -44,16 +42,6 @@ export default function NoteListPage({ index }: { index?: number }) {
|
|||
return { urls: relayUrls }
|
||||
}, [searchParams, relayUrlsString])
|
||||
|
||||
if (filter?.search && searchableRelayUrls.length === 0) {
|
||||
return (
|
||||
<SecondaryPageLayout index={index} 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 index={index} titlebarContent={title} displayScrollToTopButton>
|
||||
<NoteList key={title} filter={filter} relayUrls={urls} />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import UserItem from '@/components/UserItem'
|
||||
import { useSearchParams } from '@/hooks'
|
||||
import { SEARCHABLE_RELAY_URLS } from '@/constants'
|
||||
import { useFetchRelayInfos, useSearchParams } from '@/hooks'
|
||||
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { useRelaySettings } from '@/providers/RelaySettingsProvider'
|
||||
import { useFeed } from '@/providers/FeedProvider'
|
||||
import client from '@/services/client.service'
|
||||
import dayjs from 'dayjs'
|
||||
import { Filter } from 'nostr-tools'
|
||||
|
|
@ -13,7 +14,8 @@ const LIMIT = 50
|
|||
export default function ProfileListPage({ index }: { index?: number }) {
|
||||
const { t } = useTranslation()
|
||||
const { searchParams } = useSearchParams()
|
||||
const { relayUrls, searchableRelayUrls } = useRelaySettings()
|
||||
const { relayUrls } = useFeed()
|
||||
const { searchableRelayUrls } = useFetchRelayInfos(relayUrls)
|
||||
const [until, setUntil] = useState<number>(() => dayjs().unix())
|
||||
const [hasMore, setHasMore] = useState<boolean>(true)
|
||||
const [pubkeySet, setPubkeySet] = useState(new Set<string>())
|
||||
|
|
@ -27,7 +29,7 @@ export default function ProfileListPage({ index }: { index?: number }) {
|
|||
return f
|
||||
}, [searchParams, until])
|
||||
const urls = useMemo(() => {
|
||||
return filter.search ? searchableRelayUrls : relayUrls
|
||||
return filter.search ? searchableRelayUrls.concat(SEARCHABLE_RELAY_URLS).slice(0, 4) : relayUrls
|
||||
}, [relayUrls, searchableRelayUrls, filter])
|
||||
const title = useMemo(() => {
|
||||
return filter.search ? `${t('Search')}: ${filter.search}` : t('All users')
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
|||
import { toFollowingList } from '@/lib/link'
|
||||
import { generateImageByPubkey } from '@/lib/pubkey'
|
||||
import { SecondaryPageLink } from '@/PageManager'
|
||||
import { useFeed } from '@/providers/FeedProvider'
|
||||
import { useFollowList } from '@/providers/FollowListProvider'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import { useRelaySettings } from '@/providers/RelaySettingsProvider'
|
||||
import { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import NotFoundPage from '../NotFoundPage'
|
||||
|
|
@ -24,9 +24,12 @@ export default function ProfilePage({ id, index }: { id?: string; index?: number
|
|||
const { t } = useTranslation()
|
||||
const { profile, isFetching } = useFetchProfile(id)
|
||||
const { relayList, isFetching: isFetchingRelayInfo } = useFetchRelayList(profile?.pubkey)
|
||||
const { relayUrls: currentRelayUrls } = useRelaySettings()
|
||||
const { relayUrls: currentRelayUrls } = useFeed()
|
||||
const relayUrls = useMemo(
|
||||
() => relayList.write.slice(0, 4).concat(currentRelayUrls.slice(0, 1)),
|
||||
() =>
|
||||
relayList.write.length < 4
|
||||
? relayList.write.concat(currentRelayUrls).slice(0, 4)
|
||||
: relayList.write.slice(0, 4),
|
||||
[relayList, currentRelayUrls]
|
||||
)
|
||||
const { pubkey: accountPubkey } = useNostr()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import RelaySettings from '@/components/RelaySettings'
|
||||
import RelaySetsSetting from '@/components/RelaySetsSetting'
|
||||
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ export default function RelaySettingsPage({ index }: { index?: number }) {
|
|||
return (
|
||||
<SecondaryPageLayout index={index} titlebarContent={t('Relay settings')}>
|
||||
<div className="px-4">
|
||||
<RelaySettings hideTitle />
|
||||
<RelaySetsSetting />
|
||||
</div>
|
||||
</SecondaryPageLayout>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue