From ee90ae99c157bca340d98b0b86de30e8641f31bd Mon Sep 17 00:00:00 2001 From: codytseng Date: Mon, 19 Jan 2026 22:07:53 +0800 Subject: [PATCH] feat: render relay description content --- src/components/RelayInfo/index.tsx | 4 +++- src/lib/event.ts | 3 ++- src/lib/random.ts | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/RelayInfo/index.tsx b/src/components/RelayInfo/index.tsx index 9c03706..eb59971 100644 --- a/src/components/RelayInfo/index.tsx +++ b/src/components/RelayInfo/index.tsx @@ -17,6 +17,8 @@ import SaveRelayDropdownMenu from '../SaveRelayDropdownMenu' import UserAvatar from '../UserAvatar' import Username from '../Username' import RelayReviewsPreview from './RelayReviewsPreview' +import Content from '../Content' +import { createFakeEvent } from '@/lib/event' export default function RelayInfo({ url, className }: { url: string; className?: string }) { const { t } = useTranslation() @@ -53,7 +55,7 @@ export default function RelayInfo({ url, className }: { url: string; className?: )} {relayInfo.description && (
- {relayInfo.description} +
)} diff --git a/src/lib/event.ts b/src/lib/event.ts index e40cefe..3c3a1a9 100644 --- a/src/lib/event.ts +++ b/src/lib/event.ts @@ -10,6 +10,7 @@ import { getImetaInfoFromImetaTag, tagNameEquals } from './tag' +import { randomString } from './random' const EVENT_EMBEDDED_NOTES_CACHE = new LRUCache({ max: 10000 }) const EVENT_EMBEDDED_PUBKEYS_CACHE = new LRUCache({ max: 10000 }) @@ -347,7 +348,7 @@ export function getReplaceableEventIdentifier(event: Event) { export function createFakeEvent(event: Partial): Event { return { - id: '', + id: randomString(64, { hex: true }), kind: 1, pubkey: '', content: '', diff --git a/src/lib/random.ts b/src/lib/random.ts index a8f76f6..6183904 100644 --- a/src/lib/random.ts +++ b/src/lib/random.ts @@ -1,9 +1,11 @@ const SEED = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' +const HEX_SEED = 'abcdef0123456789' -export function randomString(len = 32) { +export function randomString(len = 32, { hex } = { hex: false }) { let str = '' + const seed = hex ? HEX_SEED : SEED for (let i = 0; i < len; i++) { - str += SEED[Math.floor(Math.random() * SEED.length)] + str += seed[Math.floor(Math.random() * SEED.length)] } return str }