From 36c9796ea1efa92e892a775c105d37fbbf21151e Mon Sep 17 00:00:00 2001 From: codytseng Date: Thu, 23 Oct 2025 23:38:44 +0800 Subject: [PATCH] feat: relay reviews tab --- src/components/Note/RelayReview.tsx | 21 ++++++++++++++++++++- src/constants.ts | 4 ++-- src/i18n/locales/ar.ts | 3 ++- src/i18n/locales/de.ts | 3 ++- src/i18n/locales/en.ts | 3 ++- src/i18n/locales/es.ts | 3 ++- src/i18n/locales/fa.ts | 3 ++- src/i18n/locales/fr.ts | 3 ++- src/i18n/locales/hi.ts | 3 ++- src/i18n/locales/it.ts | 3 ++- src/i18n/locales/ja.ts | 3 ++- src/i18n/locales/ko.ts | 3 ++- src/i18n/locales/pl.ts | 3 ++- src/i18n/locales/pt-BR.ts | 3 ++- src/i18n/locales/pt-PT.ts | 3 ++- src/i18n/locales/ru.ts | 3 ++- src/i18n/locales/th.ts | 3 ++- src/i18n/locales/zh.ts | 3 ++- src/lib/tag.ts | 3 ++- src/pages/primary/ExplorePage/index.tsx | 20 ++++++++++++++++++-- 20 files changed, 74 insertions(+), 22 deletions(-) diff --git a/src/components/Note/RelayReview.tsx b/src/components/Note/RelayReview.tsx index 4919311d..076a6ba3 100644 --- a/src/components/Note/RelayReview.tsx +++ b/src/components/Note/RelayReview.tsx @@ -1,15 +1,34 @@ +import { getReplaceableEventIdentifier } from '@/lib/event' import { getStarsFromRelayReviewEvent } from '@/lib/event-metadata' +import { toRelay } from '@/lib/link' +import { simplifyUrl } from '@/lib/url' +import { useSecondaryPage } from '@/PageManager' import { Event } from 'nostr-tools' import { useMemo } from 'react' import Content from '../Content' import Stars from '../Stars' export default function RelayReview({ event, className }: { event: Event; className?: string }) { + const { push } = useSecondaryPage() const stars = useMemo(() => getStarsFromRelayReviewEvent(event), [event]) + const url = useMemo(() => getReplaceableEventIdentifier(event), [event]) + const simplifiedUrl = useMemo(() => simplifyUrl(url), [url]) return (
- +
+ + +
{ + e.stopPropagation() + push(toRelay(url)) + }} + > + {simplifiedUrl} +
+
) diff --git a/src/constants.ts b/src/constants.ts index c890232b..de3f238e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -68,9 +68,9 @@ export const ApplicationDataKey = { export const BIG_RELAY_URLS = [ 'wss://relay.damus.io/', - 'wss://nos.lol/', 'wss://relay.nostr.band/', - 'wss://nostr.mom/' + 'wss://relay.primal.net/', + 'wss://nos.lol/' ] export const SEARCHABLE_RELAY_URLS = ['wss://relay.nostr.band/', 'wss://search.nos.today/'] diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index f79aa82f..25f7fa01 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -479,6 +479,7 @@ export default { 'Primary color': 'اللون الأساسي', Layout: 'التخطيط', 'Two-column': 'عمودين', - 'Single-column': 'عمود واحد' + 'Single-column': 'عمود واحد', + Reviews: 'المراجعات' } } diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 2294aa3c..556f523b 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -493,6 +493,7 @@ export default { 'Primary color': 'Primärfarbe', Layout: 'Layout', 'Two-column': 'Zweispaltig', - 'Single-column': 'Einspaltig' + 'Single-column': 'Einspaltig', + Reviews: 'Bewertungen' } } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index b79625da..95ac13ff 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -478,6 +478,7 @@ export default { 'Primary color': 'Primary color', Layout: 'Layout', 'Two-column': 'Two-column', - 'Single-column': 'Single-column' + 'Single-column': 'Single-column', + Reviews: 'Reviews' } } diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index f065135f..1f1fbe51 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -487,6 +487,7 @@ export default { 'Primary color': 'Color primario', Layout: 'Diseño', 'Two-column': 'Doble columna', - 'Single-column': 'Columna única' + 'Single-column': 'Columna única', + Reviews: 'Reseñas' } } diff --git a/src/i18n/locales/fa.ts b/src/i18n/locales/fa.ts index 38dcccde..29e1845b 100644 --- a/src/i18n/locales/fa.ts +++ b/src/i18n/locales/fa.ts @@ -482,6 +482,7 @@ export default { 'Primary color': 'رنگ اصلی', Layout: 'چیدمان', 'Two-column': 'دو ستونی', - 'Single-column': 'تک ستونی' + 'Single-column': 'تک ستونی', + Reviews: 'نقدها' } } diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 936291ca..acf3de55 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -492,6 +492,7 @@ export default { 'Primary color': 'Couleur principale', Layout: 'Disposition', 'Two-column': 'Deux colonnes', - 'Single-column': 'Une seule colonne' + 'Single-column': 'Une seule colonne', + Reviews: 'Avis' } } diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index 77bba4fe..a3f81049 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -484,6 +484,7 @@ export default { 'Primary color': 'प्राथमिक रंग', Layout: 'लेआउट', 'Two-column': 'दोहरा स्तंभ', - 'Single-column': 'एकल स्तंभ' + 'Single-column': 'एकल स्तंभ', + Reviews: 'समीक्षाएं' } } diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index 55758c01..16e5618f 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -487,6 +487,7 @@ export default { 'Primary color': 'Colore primario', Layout: 'Layout', 'Two-column': 'Doppia colonna', - 'Single-column': 'Colonna singola' + 'Single-column': 'Colonna singola', + Reviews: 'Recensioni' } } diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index 379bdba3..6458dfa8 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -483,6 +483,7 @@ export default { 'Primary color': '主要な色', Layout: 'レイアウト', 'Two-column': '2列', - 'Single-column': '1列' + 'Single-column': '1列', + Reviews: 'レビュー' } } diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index c0716d2d..dcc953c0 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -483,6 +483,7 @@ export default { 'Primary color': '기본 색상', Layout: '레이아웃', 'Two-column': '두 열', - 'Single-column': '한 열' + 'Single-column': '한 열', + Reviews: '리뷰' } } diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 330a05d3..bfce50c9 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -487,6 +487,7 @@ export default { 'Primary color': 'Kolor podstawowy', Layout: 'Układ', 'Two-column': 'Dwie kolumny', - 'Single-column': 'Jedna kolumna' + 'Single-column': 'Jedna kolumna', + Reviews: 'Opinie' } } diff --git a/src/i18n/locales/pt-BR.ts b/src/i18n/locales/pt-BR.ts index 0b898bd1..4bac4dad 100644 --- a/src/i18n/locales/pt-BR.ts +++ b/src/i18n/locales/pt-BR.ts @@ -484,6 +484,7 @@ export default { 'Primary color': 'Cor primária', Layout: 'Layout', 'Two-column': 'Coluna dupla', - 'Single-column': 'Coluna única' + 'Single-column': 'Coluna única', + Reviews: 'Avaliações' } } diff --git a/src/i18n/locales/pt-PT.ts b/src/i18n/locales/pt-PT.ts index d294e462..2ed6abfb 100644 --- a/src/i18n/locales/pt-PT.ts +++ b/src/i18n/locales/pt-PT.ts @@ -487,6 +487,7 @@ export default { 'Primary color': 'Cor primária', Layout: 'Layout', 'Two-column': 'Coluna dupla', - 'Single-column': 'Coluna única' + 'Single-column': 'Coluna única', + Reviews: 'Avaliações' } } diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index b4b32821..5549a761 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -489,6 +489,7 @@ export default { 'Primary color': 'Основной цвет', Layout: 'Макет', 'Two-column': 'Две колонки', - 'Single-column': 'Одна колонка' + 'Single-column': 'Одна колонка', + Reviews: 'Отзывы' } } diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index 8cd79f7c..c2f6693e 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -477,6 +477,7 @@ export default { 'Primary color': 'สีหลัก', Layout: 'เค้าโครง', 'Two-column': 'สองคอลัมน์', - 'Single-column': 'คอลัมน์เดียว' + 'Single-column': 'คอลัมน์เดียว', + Reviews: 'รีวิว' } } diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 1d37c8f8..142b61ca 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -475,6 +475,7 @@ export default { 'Primary color': '主色调', Layout: '布局', 'Two-column': '双栏', - 'Single-column': '单栏' + 'Single-column': '单栏', + Reviews: '评价' } } diff --git a/src/lib/tag.ts b/src/lib/tag.ts index a4a121c3..7804e63a 100644 --- a/src/lib/tag.ts +++ b/src/lib/tag.ts @@ -34,7 +34,8 @@ export function generateBech32IdFromETag(tag: string[]) { export function generateBech32IdFromATag(tag: string[]) { try { const [, coordinate, relay] = tag - const [kind, pubkey, identifier] = coordinate.split(':') + const [kind, pubkey, ...items] = coordinate.split(':') + const identifier = items.join(':') return nip19.naddrEncode({ kind: Number(kind), pubkey, diff --git a/src/pages/primary/ExplorePage/index.tsx b/src/pages/primary/ExplorePage/index.tsx index 60aba62c..242da526 100644 --- a/src/pages/primary/ExplorePage/index.tsx +++ b/src/pages/primary/ExplorePage/index.tsx @@ -1,15 +1,19 @@ import Explore from '@/components/Explore' import FollowingFavoriteRelayList from '@/components/FollowingFavoriteRelayList' +import NoteList from '@/components/NoteList' import Tabs from '@/components/Tabs' import { Button } from '@/components/ui/button' +import { BIG_RELAY_URLS, ExtendedKind } from '@/constants' import PrimaryPageLayout from '@/layouts/PrimaryPageLayout' +import { useUserTrust } from '@/providers/UserTrustProvider' import { Compass, Plus } from 'lucide-react' import { forwardRef, useState } from 'react' import { useTranslation } from 'react-i18next' -type TExploreTabs = 'following' | 'explore' +type TExploreTabs = 'following' | 'explore' | 'reviews' const ExplorePage = forwardRef((_, ref) => { + const { hideUntrustedNotes } = useUserTrust() const [tab, setTab] = useState('explore') return ( @@ -23,11 +27,23 @@ const ExplorePage = forwardRef((_, ref) => { value={tab} tabs={[ { value: 'explore', label: 'Explore' }, + { value: 'reviews', label: 'Reviews' }, { value: 'following', label: "Following's Favorites" } ]} onTabChange={(tab) => setTab(tab as TExploreTabs)} /> - {tab === 'following' ? : } + {tab === 'explore' ? ( + + ) : tab === 'reviews' ? ( + + ) : ( + + )} ) })