From 87adf1638ed6be953e0905e80c556f4084302f46 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 31 May 2026 16:53:38 +0200 Subject: [PATCH] bug-fixes --- src/components/MailboxSetting/RelayCountWarning.tsx | 13 +++++++------ src/components/TooManyRelaysAlertDialog/index.tsx | 8 ++++++-- src/constants.ts | 11 +++++++---- src/i18n/locales/en.ts | 8 ++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/components/MailboxSetting/RelayCountWarning.tsx b/src/components/MailboxSetting/RelayCountWarning.tsx index 584aa294..79c526d4 100644 --- a/src/components/MailboxSetting/RelayCountWarning.tsx +++ b/src/components/MailboxSetting/RelayCountWarning.tsx @@ -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[] 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[] 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 } ) } /> diff --git a/src/components/TooManyRelaysAlertDialog/index.tsx b/src/components/TooManyRelaysAlertDialog/index.tsx index 9c78e8c1..108038f7 100644 --- a/src/components/TooManyRelaysAlertDialog/index.tsx +++ b/src/components/TooManyRelaysAlertDialog/index.tsx @@ -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() { 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) diff --git a/src/constants.ts b/src/constants.ts index 207c99f6..c39b0d27 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 = [ '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 = [ 'wss://relay.damus.io', 'wss://relay.primal.net', 'wss://thecitadel.nostr1.com', - 'wss://nos.lol', - 'wss://relay.layer.systems' + 'wss://nos.lol' ] /** diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 214d40d1..d37d308d 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -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.',