Browse Source

bug-fixes

imwald
Silberengel 2 weeks ago
parent
commit
87adf1638e
  1. 13
      src/components/MailboxSetting/RelayCountWarning.tsx
  2. 8
      src/components/TooManyRelaysAlertDialog/index.tsx
  3. 11
      src/constants.ts
  4. 8
      src/i18n/locales/en.ts

13
src/components/MailboxSetting/RelayCountWarning.tsx

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
import { MAILBOX_RELAY_COUNT_WARNING_THRESHOLD } from '@/constants'
import { TMailboxRelay } from '@/types'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
@ -11,8 +12,8 @@ export default function RelayCountWarning({ relays }: { relays: TMailboxRelay[] @@ -11,8 +12,8 @@ export default function RelayCountWarning({ relays }: { relays: TMailboxRelay[]
const writeRelayCount = useMemo(() => {
return relays.filter((r) => r.scope !== 'read').length
}, [relays])
const showReadWarning = readRelayCount > 4
const showWriteWarning = writeRelayCount > 4
const showReadWarning = readRelayCount >= MAILBOX_RELAY_COUNT_WARNING_THRESHOLD
const showWriteWarning = writeRelayCount >= MAILBOX_RELAY_COUNT_WARNING_THRESHOLD
if (!showReadWarning && !showWriteWarning) {
return null
@ -24,12 +25,12 @@ export default function RelayCountWarning({ relays }: { relays: TMailboxRelay[] @@ -24,12 +25,12 @@ export default function RelayCountWarning({ relays }: { relays: TMailboxRelay[]
content={
showReadWarning
? t(
'You have {{count}} read relays. Most clients only use 2-4 relays, setting more is unnecessary.',
{ count: readRelayCount }
'You have {{count}} read relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.',
{ count: readRelayCount, limit: MAILBOX_RELAY_COUNT_WARNING_THRESHOLD }
)
: t(
'You have {{count}} write relays. Most clients only use 2-4 relays, setting more is unnecessary.',
{ count: writeRelayCount }
'You have {{count}} write relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.',
{ count: writeRelayCount, limit: MAILBOX_RELAY_COUNT_WARNING_THRESHOLD }
)
}
/>

8
src/components/TooManyRelaysAlertDialog/index.tsx

@ -16,7 +16,7 @@ import { @@ -16,7 +16,7 @@ import {
DrawerHeader,
DrawerTitle
} from '@/components/ui/drawer'
import { toRelaySettings } from '@/lib/link'
import { MAILBOX_RELAY_COUNT_WARNING_THRESHOLD } from '@/constants'
import { useSecondaryPage } from '@/contexts/secondary-page-context'
import { useNostr } from '@/providers/NostrProvider'
import { useScreenSize } from '@/providers/ScreenSizeProvider'
@ -34,7 +34,11 @@ export default function TooManyRelaysAlertDialog() { @@ -34,7 +34,11 @@ export default function TooManyRelaysAlertDialog() {
const dismissed = storage.getDismissedTooManyRelaysAlert()
if (dismissed) return
if (relayList && (relayList.read.length > 4 || relayList.write.length > 4)) {
if (
relayList &&
(relayList.read.length >= MAILBOX_RELAY_COUNT_WARNING_THRESHOLD ||
relayList.write.length >= MAILBOX_RELAY_COUNT_WARNING_THRESHOLD)
) {
setOpen(true)
} else {
setOpen(false)

11
src/constants.ts

@ -430,6 +430,9 @@ export const FONT_SIZE = { @@ -430,6 +430,9 @@ export const FONT_SIZE = {
*/
export const RANDOM_PUBLISH_RELAY_COUNT = 5
/** Read or write mailbox count above this triggers “too many relays” warnings and the optimize dialog. */
export const MAILBOX_RELAY_COUNT_WARNING_THRESHOLD = 10
/** Relays to query for NIP-66 relay monitoring events (30166), in addition to FAST_READ_RELAY_URLS. */
export const NIP66_DISCOVERY_RELAY_URLS = [
'wss://thecitadel.nostr1.com',
@ -500,12 +503,13 @@ export const SOCIAL_KIND_BLOCKED_RELAY_URLS = [ @@ -500,12 +503,13 @@ export const SOCIAL_KIND_BLOCKED_RELAY_URLS = [
'wss://hist.nostr.land',
]
// Optimized relay list for read operations (includes aggregator)
// Optimized relay list for read operations
export const FAST_READ_RELAY_URLS = [
'wss://theforest.nostr1.com',
'wss://nostr.land',
'wss://nostr.wine',
'wss://nostr21.com'
'wss://nostr21.com',
'wss://primus.nostr1.com'
]
// Optimized relay list for write operations (no aggregator since it's read-only)
@ -513,8 +517,7 @@ export const FAST_WRITE_RELAY_URLS = [ @@ -513,8 +517,7 @@ export const FAST_WRITE_RELAY_URLS = [
'wss://relay.damus.io',
'wss://relay.primal.net',
'wss://thecitadel.nostr1.com',
'wss://nos.lol',
'wss://relay.layer.systems'
'wss://nos.lol'
]
/**

8
src/i18n/locales/en.ts

@ -1235,10 +1235,10 @@ export default { @@ -1235,10 +1235,10 @@ export default {
'After changing emojis, you may need to refresh the page',
'Too many read relays': 'Too many read relays',
'Too many write relays': 'Too many write relays',
'You have {{count}} read relays. Most clients only use 2-4 relays, setting more is unnecessary.':
'You have {{count}} read relays. Most clients only use 2-4 relays, setting more is unnecessary.',
'You have {{count}} write relays. Most clients only use 2-4 relays, setting more is unnecessary.':
'You have {{count}} write relays. Most clients only use 2-4 relays, setting more is unnecessary.',
'You have {{count}} read relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.':
'You have {{count}} read relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.',
'You have {{count}} write relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.':
'You have {{count}} write relays. Most clients only use up to {{limit}} relays, setting more is unnecessary.',
'Optimize Relay Settings': 'Optimize Relay Settings',
'Your current relay configuration may not be optimal. This could make it difficult for others to find your posts and may result in incomplete notifications.':
'Your current relay configuration may not be optimal. This could make it difficult for others to find your posts and may result in incomplete notifications.',

Loading…
Cancel
Save