From e3d974e2b98df3fe8b56c39a90f68667e1c62f3a Mon Sep 17 00:00:00 2001 From: Silberengel Date: Mon, 1 Jun 2026 16:41:24 +0200 Subject: [PATCH] move session relays to last tab include trending relay in the onboarding favorites template --- src/constants.ts | 1 + src/lib/new-user-template.test.ts | 14 ++++++++++++-- src/lib/new-user-template.ts | 9 ++++++++- src/pages/secondary/RelaySettingsPage/index.tsx | 8 ++++---- src/services/client.service.ts | 7 +++---- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index c5bcba9d..aca8b1e3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -74,6 +74,7 @@ export const DESKTOP_APP_DOWNLOAD_URL_DEFAULT = export const DEFAULT_FAVORITE_RELAYS = [ 'wss://theforest.nostr1.com', 'wss://nostr.land', + 'wss://feeds.nostrarchives.com/notes/trending/reactions/today' ] /** diff --git a/src/lib/new-user-template.test.ts b/src/lib/new-user-template.test.ts index ce1b5487..2c72a532 100644 --- a/src/lib/new-user-template.test.ts +++ b/src/lib/new-user-template.test.ts @@ -1,7 +1,15 @@ import { describe, expect, it } from 'vitest' import { kinds } from 'nostr-tools' import { ExtendedKind, FAST_READ_RELAY_URLS, FAST_WRITE_RELAY_URLS } from '@/constants' -import { NEW_USER_BLOCKED_RELAY_URLS, NEW_USER_HTTP_RELAY_URL, buildNewUserTemplateDrafts, newUserProfileDisplayName, newUserProfileName, newUserProfileSuffix } from '@/lib/new-user-template' +import { + NEW_USER_BLOCKED_RELAY_URLS, + NEW_USER_HTTP_RELAY_URL, + NEW_USER_TRENDING_RELAY_URL, + buildNewUserTemplateDrafts, + newUserProfileDisplayName, + newUserProfileName, + newUserProfileSuffix +} from '@/lib/new-user-template' import { newUserTemplatePublishRelays } from '@/lib/new-user-template-broadcast' import { normalizeAnyRelayUrl } from '@/lib/url' import type { TRelayList } from '@/types' @@ -55,7 +63,9 @@ describe('buildNewUserTemplateDrafts', () => { it('builds favorite relays kind 10012', () => { expect(drafts.favoriteRelays.kind).toBe(ExtendedKind.FAVORITE_RELAYS) - expect(drafts.favoriteRelays.tags.filter((t) => t[0] === 'relay')).toHaveLength(2) + const favorites = drafts.favoriteRelays.tags.filter((t) => t[0] === 'relay').map((t) => t[1]) + expect(favorites).toContain(NEW_USER_TRENDING_RELAY_URL) + expect(favorites).toHaveLength(3) }) it('builds blocked relays kind 10006 with dead relays', () => { diff --git a/src/lib/new-user-template.ts b/src/lib/new-user-template.ts index 0b4dd12c..2801d061 100644 --- a/src/lib/new-user-template.ts +++ b/src/lib/new-user-template.ts @@ -3,6 +3,7 @@ import { FAST_READ_RELAY_URLS, FAST_WRITE_RELAY_URLS } from '@/constants' +import { buildWispTrendingNotesRelayUrl } from '@/lib/wisp-trending-relay' import { createBlockedRelaysDraftEvent, createFavoriteRelaysDraftEvent, @@ -17,6 +18,9 @@ import { TDraftEvent, TMailboxRelay } from '@/types' export const NEW_USER_HTTP_RELAY_URL = 'https://mercury-relay.imwald.eu/' +/** nostrarchives trending notes (reactions / today) — read-only feed for new accounts. */ +export const NEW_USER_TRENDING_RELAY_URL = buildWispTrendingNotesRelayUrl('reactions', 'today') + /** Dead relays seeded into kind 10006 for new accounts. */ export const NEW_USER_BLOCKED_RELAY_URLS = [ 'wss://orly-relay.imwald.eu', @@ -70,7 +74,10 @@ export function buildNewUserProfileDraft(pubkey: string): TDraftEvent { } export function buildNewUserFavoriteRelaysDraft(): TDraftEvent { - return createFavoriteRelaysDraftEvent([...DEFAULT_FAVORITE_RELAYS], []) + return createFavoriteRelaysDraftEvent( + [...DEFAULT_FAVORITE_RELAYS, NEW_USER_TRENDING_RELAY_URL], + [] + ) } export function buildNewUserBlockedRelaysDraft(): TDraftEvent { diff --git a/src/pages/secondary/RelaySettingsPage/index.tsx b/src/pages/secondary/RelaySettingsPage/index.tsx index 5d91c809..d0a125a9 100644 --- a/src/pages/secondary/RelaySettingsPage/index.tsx +++ b/src/pages/secondary/RelaySettingsPage/index.tsx @@ -125,8 +125,8 @@ const RelaySettingsPage = forwardRef(({ index, hideTitlebar = false }: { index?: {t('Favorite Relays')} {t('Read & Write Relays')} {t('HTTP relays')} - {t('Session relays')} {t('Cache Relays')} + {t('Session relays')} @@ -137,12 +137,12 @@ const RelaySettingsPage = forwardRef(({ index, hideTitlebar = false }: { index?: - - - + + + ) diff --git a/src/services/client.service.ts b/src/services/client.service.ts index d540ba79..69fce94d 100644 --- a/src/services/client.service.ts +++ b/src/services/client.service.ts @@ -71,7 +71,7 @@ import { import { filterViewerBlockedRelaysForFetch, getViewerBlockedRelayUrls, - isRelayBlockedByUser, + isViewerRelayBlocked, parseBlockedRelayUrlsFromEvent, setViewerBlockedRelayUrls } from '@/lib/viewer-blocked-relays' @@ -844,11 +844,10 @@ class ClientService extends EventTarget { /** Close pooled sockets to relays on the viewer block list (hostname-aware, wss/https). */ closeViewerBlockedRelayConnections(): void { - const blocked = getViewerBlockedRelayUrls() - if (!blocked.length) return + if (!getViewerBlockedRelayUrls().length) return try { const toClose = [...this.pool.listConnectionStatus().keys()].filter((url) => - isRelayBlockedByUser(url, blocked) + isViewerRelayBlocked(url) ) if (toClose.length > 0) this.pool.close(toClose) } catch {