feat: calculate optimal read relays
This commit is contained in:
parent
4211f831bf
commit
9db979c31d
5 changed files with 325 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import { useNostr } from '@/providers/NostrProvider'
|
|||
import { TMailboxRelay, TMailboxRelayScope } from '@/types'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import CalculateOptimalReadRelaysButton from './CalculateOptimalReadRelaysButton'
|
||||
import MailboxRelay from './MailboxRelay'
|
||||
import NewMailboxRelayInput from './NewMailboxRelayInput'
|
||||
import SaveButton from './SaveButton'
|
||||
|
|
@ -49,6 +50,13 @@ export default function MailboxSetting() {
|
|||
return null
|
||||
}
|
||||
|
||||
const mergeRelays = (newRelays: TMailboxRelay[]) => {
|
||||
setRelays((pre) => {
|
||||
return [...pre, ...newRelays.filter((r) => !pre.some((pr) => pr.url === r.url))]
|
||||
})
|
||||
setHasChange(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="text-xs text-muted-foreground space-y-1">
|
||||
|
|
@ -56,6 +64,7 @@ export default function MailboxSetting() {
|
|||
<div>{t('write relays description')}</div>
|
||||
<div>{t('read & write relays notice')}</div>
|
||||
</div>
|
||||
<CalculateOptimalReadRelaysButton mergeRelays={mergeRelays} />
|
||||
<SaveButton mailboxRelays={relays} hasChange={hasChange} setHasChange={setHasChange} />
|
||||
<div className="space-y-2">
|
||||
{relays.map((relay) => (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue