diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 3d21447a..99604756 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -1,7 +1,6 @@ import Sidebar from '@/components/Sidebar' import { cn } from '@/lib/utils' import NoteListPage from '@/pages/primary/NoteListPage' -import HomePage from '@/pages/secondary/HomePage' import { CurrentRelaysProvider } from '@/providers/CurrentRelaysProvider' import { TPageRef } from '@/types' import { @@ -455,7 +454,8 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
{secondaryStack.map((item, index) => ( @@ -467,13 +467,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { {item.component}
))} -
- -
diff --git a/src/components/FeedSwitcher/index.tsx b/src/components/FeedSwitcher/index.tsx index bd094856..6da33769 100644 --- a/src/components/FeedSwitcher/index.tsx +++ b/src/components/FeedSwitcher/index.tsx @@ -1,5 +1,6 @@ import { toRelaySettings } from '@/lib/link' import { simplifyUrl } from '@/lib/url' +import { cn } from '@/lib/utils' import { SecondaryPageLink } from '@/PageManager' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import { useFeed } from '@/providers/FeedProvider' @@ -17,23 +18,22 @@ export default function FeedSwitcher({ close }: { close?: () => void }) { return (
- {pubkey && ( - { - if (!pubkey) return - switchFeed('following', { pubkey }) - close?.() - }} - > -
-
- -
-
{t('Following')}
+ { + if (!pubkey) return + switchFeed('following', { pubkey }) + close?.() + }} + > +
+
+
- - )} +
{t('Following')}
+
+
void }) { { if (!select) return switchFeed('relays', { activeRelaySetId: set.id }) @@ -61,7 +61,7 @@ export default function FeedSwitcher({ close }: { close?: () => void }) { {favoriteRelays.map((relay) => ( { switchFeed('relay', { relay }) close?.() @@ -80,18 +80,27 @@ export default function FeedSwitcher({ close }: { close?: () => void }) { function FeedSwitcherItem({ children, isActive, + disabled, onClick, controls }: { children: React.ReactNode isActive: boolean + disabled?: boolean onClick: () => void controls?: React.ReactNode }) { return (
{ + if (disabled) return + onClick() + }} >
{children}
diff --git a/src/constants.ts b/src/constants.ts index d52c1dad..44949fbc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,18 +2,6 @@ import { kinds } from 'nostr-tools' export const JUMBLE_API_BASE_URL = 'https://api.jumble.social' -export const DEFAULT_FAVORITE_RELAYS = [ - 'wss://nostr.wine/', - 'wss://pyramid.fiatjaf.com/', - 'wss://relays.land/spatianostra/', - 'wss://theforest.nostr1.com/', - 'wss://algo.utxo.one/', - 'wss://140.f7z.io/', - 'wss://news.utxo.one/' -] - -export const RECOMMENDED_RELAYS = DEFAULT_FAVORITE_RELAYS.concat(['wss://yabu.me/']) - export const RECOMMENDED_BLOSSOM_SERVERS = [ 'https://blossom.band/', 'https://blossom.primal.net/', diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index 9d5ee621..a185ab91 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -484,6 +484,11 @@ export default { Extension: 'امتداد', Remote: 'عن بُعد', 'Encrypted Key': 'مفتاح مشفر', - 'Private Key': 'مفتاح خاص' + 'Private Key': 'مفتاح خاص', + 'Welcome to Jumble': 'مرحبًا بك في Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble هو عميل يركز على تصفح المرحلات. ابدأ باستكشاف المرحلات المثيرة للاهتمام أو قم بتسجيل الدخول لعرض خلاصتك.', + 'Explore Relays': 'استكشف المرحلات', + 'Choose a feed': 'اختر خلاصة' } } diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index b72e4e53..2a879f5b 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -498,6 +498,11 @@ export default { Extension: 'Erweiterung', Remote: 'Remote', 'Encrypted Key': 'Verschlüsselter Schlüssel', - 'Private Key': 'Privater Schlüssel' + 'Private Key': 'Privater Schlüssel', + 'Welcome to Jumble': 'Willkommen bei Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble ist ein Client, der sich auf das Durchsuchen von Relays konzentriert. Beginnen Sie mit der Erkundung interessanter Relays oder melden Sie sich an, um Ihren Following-Feed anzuzeigen.', + 'Explore Relays': 'Relays erkunden', + 'Choose a feed': 'Wähle einen Feed' } } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 217402a1..9afbfa15 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -483,6 +483,11 @@ export default { Extension: 'Extension', Remote: 'Remote', 'Encrypted Key': 'Encrypted Key', - 'Private Key': 'Private Key' + 'Private Key': 'Private Key', + 'Welcome to Jumble': 'Welcome to Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.', + 'Explore Relays': 'Explore Relays', + 'Choose a feed': 'Choose a feed' } } diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index 08eebea5..57ae48b4 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -492,6 +492,11 @@ export default { Extension: 'Extensión', Remote: 'Remoto', 'Encrypted Key': 'Clave privada cifrada', - 'Private Key': 'Clave privada' + 'Private Key': 'Clave privada', + 'Welcome to Jumble': 'Bienvenido a Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble es un cliente enfocado en explorar relays. Comienza explorando relays interesantes o inicia sesión para ver tu feed de seguidos.', + 'Explore Relays': 'Explorar Relays', + 'Choose a feed': 'Elige un feed' } } diff --git a/src/i18n/locales/fa.ts b/src/i18n/locales/fa.ts index 4a13c6bd..68139bef 100644 --- a/src/i18n/locales/fa.ts +++ b/src/i18n/locales/fa.ts @@ -487,6 +487,11 @@ export default { Extension: 'افزونه', Remote: 'از راه دور', 'Encrypted Key': 'رمزگذاری شده کلید', - 'Private Key': 'کلید خصوصی' + 'Private Key': 'کلید خصوصی', + 'Welcome to Jumble': 'به Jumble خوش آمدید', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble یک کلاینت متمرکز بر مرور رله‌هاست. با کاوش در رله‌های جالب شروع کنید یا وارد شوید تا فید دنبال‌کننده‌های خود را مشاهده کنید.', + 'Explore Relays': 'کاوش در رله‌ها', + 'Choose a feed': 'یک فید انتخاب کنید' } } diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index b192800a..a681fb60 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -497,6 +497,11 @@ export default { Extension: 'Extension', Remote: 'Distant', 'Encrypted Key': 'Clé chiffrée', - 'Private Key': 'Clé privée' + 'Private Key': 'Clé privée', + 'Welcome to Jumble': 'Bienvenue sur Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + "Jumble est un client axé sur la navigation des relais. Commencez par explorer des relais intéressants ou connectez-vous pour voir votre fil d'abonnements.", + 'Explore Relays': 'Explorer les relais', + 'Choose a feed': 'Choisir un fil' } } diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index ffdb9f0a..242d8f56 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -489,6 +489,11 @@ export default { Extension: 'एक्सटेंशन', Remote: 'रिमोट', 'Encrypted Key': 'एन्क्रिप्टेड की', - 'Private Key': 'प्राइवेट की' + 'Private Key': 'प्राइवेट की', + 'Welcome to Jumble': 'Jumble में आपका स्वागत है', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble एक क्लाइंट है जो रिले ब्राउज़ करने पर केंद्रित है। रोचक रिले की खोज करके शुरू करें या अपनी फ़ॉलोइंग फ़ीड देखने के लिए लॉगिन करें।', + 'Explore Relays': 'रिले एक्सप्लोर करें', + 'Choose a feed': 'एक फीड चुनें' } } diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index c6db57a5..0247b847 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -492,6 +492,11 @@ export default { Extension: 'Estensione', Remote: 'Remoto', 'Encrypted Key': 'Chiave Crittografata', - 'Private Key': 'Chiave Privata' + 'Private Key': 'Chiave Privata', + 'Welcome to Jumble': 'Benvenuto su Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble è un client focalizzato sulla navigazione dei relay. Inizia esplorando relay interessanti o effettua il login per visualizzare il tuo feed di following.', + 'Explore Relays': 'Esplora Relay', + 'Choose a feed': 'Scegli un feed' } } diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index badcc137..453e9ca6 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -488,6 +488,11 @@ export default { Extension: '拡張機能', Remote: 'リモート', 'Encrypted Key': '暗号化キー', - 'Private Key': '暗号化されたキー' + 'Private Key': '暗号化されたキー', + 'Welcome to Jumble': 'Jumbleへようこそ', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumbleはリレーを閲覧することに焦点を当てたクライアントです。興味深いリレーを探索するか、ログインしてフォロー中のフィードを表示してください。', + 'Explore Relays': 'リレーを探索', + 'Choose a feed': 'フィードを選択' } } diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index 679319a5..62d4822c 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -488,6 +488,11 @@ export default { Extension: '확장 프로그램', Remote: '원격', 'Encrypted Key': '암호화된 키', - 'Private Key': '개인 키' + 'Private Key': '개인 키', + 'Welcome to Jumble': 'Jumble에 오신 것을 환영합니다', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble은 릴레이 탐색에 중점을 둔 클라이언트입니다. 흥미로운 릴레이를 탐색하거나 로그인하여 팔로잉 피드를 확인하세요.', + 'Explore Relays': '릴레이 탐색', + 'Choose a feed': '피드 선택' } } diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 7bba0345..fe29e49c 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -492,6 +492,11 @@ export default { Extension: 'Rozszerzenie', Remote: 'Zdalne', 'Encrypted Key': 'Zaszyfrowany Klucz', - 'Private Key': 'Zaszyfrowany Klucz' + 'Private Key': 'Zaszyfrowany Klucz', + 'Welcome to Jumble': 'Witamy w Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble to klient skupiony na przeglądaniu relay. Zacznij od eksploracji ciekawych relay lub zaloguj się, aby zobaczyć swój feed obserwowanych.', + 'Explore Relays': 'Eksploruj Relay', + 'Choose a feed': 'Wybierz feed' } } diff --git a/src/i18n/locales/pt-BR.ts b/src/i18n/locales/pt-BR.ts index 0069aadc..b3533a3d 100644 --- a/src/i18n/locales/pt-BR.ts +++ b/src/i18n/locales/pt-BR.ts @@ -489,6 +489,11 @@ export default { Extension: 'Extensão', Remote: 'Remoto', 'Encrypted Key': 'Chave Criptografada', - 'Private Key': 'Chave Privada' + 'Private Key': 'Chave Privada', + 'Welcome to Jumble': 'Bem-vindo ao Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble é um cliente focado em navegar relays. Comece explorando relays interessantes ou faça login para ver seu feed de seguidos.', + 'Explore Relays': 'Explorar Relays', + 'Choose a feed': 'Escolha um feed' } } diff --git a/src/i18n/locales/pt-PT.ts b/src/i18n/locales/pt-PT.ts index dc4dc715..016fb8ba 100644 --- a/src/i18n/locales/pt-PT.ts +++ b/src/i18n/locales/pt-PT.ts @@ -492,6 +492,11 @@ export default { Extension: 'Extensão', Remote: 'Remoto', 'Encrypted Key': 'Chave Criptografada', - 'Private Key': 'Chave Privada' + 'Private Key': 'Chave Privada', + 'Welcome to Jumble': 'Bem-vindo ao Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble é um cliente focado em explorar relays. Comece por explorar relays interessantes ou inicie sessão para ver o seu feed de seguidos.', + 'Explore Relays': 'Explorar Relays', + 'Choose a feed': 'Escolha um feed' } } diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 5aadbd3a..3893505d 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -494,6 +494,11 @@ export default { Extension: 'Расширение', Remote: 'Удалённый', 'Encrypted Key': 'Зашифрованный ключ', - 'Private Key': 'Приватный ключ' + 'Private Key': 'Приватный ключ', + 'Welcome to Jumble': 'Добро пожаловать в Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble — это клиент, ориентированный на просмотр relay. Начните с изучения интересных relay или войдите, чтобы увидеть ленту подписок.', + 'Explore Relays': 'Исследовать Relay', + 'Choose a feed': 'Выберите ленту' } } diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index 46285b7b..a314eba8 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -482,6 +482,11 @@ export default { Extension: 'ส่วนขยาย', Remote: 'ระยะไกล', 'Encrypted Key': 'คีย์ที่เข้ารหัส', - 'Private Key': 'คีย์ส่วนตัว' + 'Private Key': 'คีย์ส่วนตัว', + 'Welcome to Jumble': 'ยินดีต้อนรับสู่ Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble เป็นไคลเอนต์ที่เน้นการเรียกดูรีเลย์ เริ่มต้นด้วยการสำรวจรีเลย์ที่น่าสนใจ หรือเข้าสู่ระบบเพื่อดูฟีดที่คุณติดตาม', + 'Explore Relays': 'สำรวจรีเลย์', + 'Choose a feed': 'เลือกฟีด' } } diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 4d5f20f5..acaa7893 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -480,6 +480,11 @@ export default { Extension: '扩展', Remote: '远程', 'Encrypted Key': '加密私钥', - 'Private Key': '私钥' + 'Private Key': '私钥', + 'Welcome to Jumble': '欢迎来到 Jumble', + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.': + 'Jumble 是一个专注于浏览服务器的客户端。从探索有趣的服务器开始,或者登录查看你的关注动态。', + 'Explore Relays': '探索服务器', + 'Choose a feed': '选择一个动态' } } diff --git a/src/pages/primary/NoteListPage/FeedButton.tsx b/src/pages/primary/NoteListPage/FeedButton.tsx index 5c50ff77..6e565664 100644 --- a/src/pages/primary/NoteListPage/FeedButton.tsx +++ b/src/pages/primary/NoteListPage/FeedButton.tsx @@ -54,21 +54,21 @@ const FeedSwitcherTrigger = forwardRef { - return feedInfo.feedType === 'relays' && feedInfo.id + return feedInfo?.feedType === 'relays' && feedInfo.id ? relaySets.find((set) => set.id === feedInfo.id) : undefined }, [feedInfo, relaySets]) const title = useMemo(() => { - if (feedInfo.feedType === 'following') { + if (feedInfo?.feedType === 'following') { return t('Following') } if (relayUrls.length === 0) { - return t('Choose a relay') + return t('Choose a feed') } - if (feedInfo.feedType === 'relay') { - return simplifyUrl(feedInfo.id ?? '') + if (feedInfo?.feedType === 'relay') { + return simplifyUrl(feedInfo?.id ?? '') } - if (feedInfo.feedType === 'relays') { + if (feedInfo?.feedType === 'relays') { return activeRelaySet?.name ?? activeRelaySet?.id } }, [feedInfo, activeRelaySet]) @@ -79,7 +79,7 @@ const FeedSwitcherTrigger = forwardRef - {feedInfo.feedType === 'following' ? : } + {feedInfo?.feedType === 'following' ? : }
{title}
diff --git a/src/pages/primary/NoteListPage/FollowingFeed.tsx b/src/pages/primary/NoteListPage/FollowingFeed.tsx index 83ef8a4c..93a6c39b 100644 --- a/src/pages/primary/NoteListPage/FollowingFeed.tsx +++ b/src/pages/primary/NoteListPage/FollowingFeed.tsx @@ -12,7 +12,7 @@ export default function FollowingFeed() { useEffect(() => { async function init() { - if (feedInfo.feedType !== 'following' || !pubkey) { + if (feedInfo?.feedType !== 'following' || !pubkey) { setSubRequests([]) return } @@ -22,7 +22,7 @@ export default function FollowingFeed() { } init() - }, [feedInfo.feedType, pubkey]) + }, [feedInfo?.feedType, pubkey]) return } diff --git a/src/pages/primary/NoteListPage/RelaysFeed.tsx b/src/pages/primary/NoteListPage/RelaysFeed.tsx index 93b73976..8c572ee0 100644 --- a/src/pages/primary/NoteListPage/RelaysFeed.tsx +++ b/src/pages/primary/NoteListPage/RelaysFeed.tsx @@ -22,7 +22,7 @@ export default function RelaysFeed() { return null } - if (feedInfo.feedType !== 'relay' && feedInfo.feedType !== 'relays') { + if (!feedInfo || (feedInfo.feedType !== 'relay' && feedInfo.feedType !== 'relays')) { return null } diff --git a/src/pages/primary/NoteListPage/index.tsx b/src/pages/primary/NoteListPage/index.tsx index 9c4f020d..b1c6c4de 100644 --- a/src/pages/primary/NoteListPage/index.tsx +++ b/src/pages/primary/NoteListPage/index.tsx @@ -1,4 +1,4 @@ -import { useSecondaryPage } from '@/PageManager' +import { usePrimaryPage, useSecondaryPage } from '@/PageManager' import PostEditor from '@/components/PostEditor' import RelayInfo from '@/components/RelayInfo' import { Button } from '@/components/ui/button' @@ -9,7 +9,7 @@ import { useFeed } from '@/providers/FeedProvider' import { useNostr } from '@/providers/NostrProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { TPageRef } from '@/types' -import { Info, PencilLine, Search } from 'lucide-react' +import { Compass, Info, LogIn, PencilLine, Search, Sparkles } from 'lucide-react' import { Dispatch, forwardRef, @@ -28,8 +28,8 @@ const NoteListPage = forwardRef((_, ref) => { const { t } = useTranslation() const { addRelayUrls, removeRelayUrls } = useCurrentRelays() const layoutRef = useRef(null) - const { pubkey, checkLogin } = useNostr() - const { feedInfo, relayUrls, isReady } = useFeed() + const { pubkey } = useNostr() + const { feedInfo, relayUrls, isReady, switchFeed } = useFeed() const [showRelayDetails, setShowRelayDetails] = useState(false) useImperativeHandle(ref, () => layoutRef.current) @@ -48,17 +48,25 @@ const NoteListPage = forwardRef((_, ref) => { } }, [relayUrls]) + if (!feedInfo) { + return ( + } + displayScrollToTopButton + > + + + ) + } + let content: React.ReactNode = null if (!isReady) { content =
{t('loading...')}
} else if (feedInfo.feedType === 'following' && !pubkey) { - content = ( -
- -
- ) + switchFeed(null) + return null } else if (feedInfo.feedType === 'following') { content = } else { @@ -169,3 +177,38 @@ function SearchButton() { ) } + +function WelcomeGuide() { + const { t } = useTranslation() + const { navigate } = usePrimaryPage() + const { checkLogin } = useNostr() + + return ( +
+
+
+ +

{t('Welcome to Jumble')}

+ +
+

+ {t( + 'Jumble is a client focused on browsing relays. Get started by exploring interesting relays or login to view your following feed.' + )} +

+
+ +
+ + + +
+
+ ) +} diff --git a/src/pages/secondary/HomePage/index.tsx b/src/pages/secondary/HomePage/index.tsx deleted file mode 100644 index a01e0ccf..00000000 --- a/src/pages/secondary/HomePage/index.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { usePrimaryPage, useSecondaryPage } from '@/PageManager' -import RelaySimpleInfo from '@/components/RelaySimpleInfo' -import { Button } from '@/components/ui/button' -import { RECOMMENDED_RELAYS } from '@/constants' -import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' -import { toRelay } from '@/lib/link' -import relayInfoService from '@/services/relay-info.service' -import { TRelayInfo } from '@/types' -import { ArrowRight, Server } from 'lucide-react' -import { forwardRef, useEffect, useState } from 'react' -import { useTranslation } from 'react-i18next' - -const HomePage = forwardRef(({ index }: { index?: number }, ref) => { - const { t } = useTranslation() - const { navigate } = usePrimaryPage() - const { push } = useSecondaryPage() - const [recommendedRelayInfos, setRecommendedRelayInfos] = useState([]) - - useEffect(() => { - const init = async () => { - try { - const relays = await relayInfoService.getRelayInfos(RECOMMENDED_RELAYS) - setRecommendedRelayInfos(relays.filter(Boolean) as TRelayInfo[]) - } catch (error) { - console.error('Failed to fetch recommended relays:', error) - } - } - init() - }, []) - - if (!recommendedRelayInfos.length) { - return ( - -
- {t('Welcome! 🥳')} -
-
- ) - } - - return ( - - -
{t('Recommended relays')}
- - } - hideBackButton - hideTitlebarBottomBorder - > -
-
- {recommendedRelayInfos.map((relayInfo) => ( - { - e.stopPropagation() - push(toRelay(relayInfo.url)) - }} - /> - ))} -
-
- -
-
-
- ) -}) -HomePage.displayName = 'HomePage' -export default HomePage diff --git a/src/providers/FavoriteRelaysProvider.tsx b/src/providers/FavoriteRelaysProvider.tsx index 63d3a98a..79fcbdc1 100644 --- a/src/providers/FavoriteRelaysProvider.tsx +++ b/src/providers/FavoriteRelaysProvider.tsx @@ -1,4 +1,4 @@ -import { BIG_RELAY_URLS, DEFAULT_FAVORITE_RELAYS } from '@/constants' +import { BIG_RELAY_URLS } from '@/constants' import { createFavoriteRelaysDraftEvent, createRelaySetDraftEvent } from '@/lib/draft-event' import { getReplaceableEventIdentifier } from '@/lib/event' import { getRelaySetFromEvent } from '@/lib/event-metadata' @@ -43,7 +43,7 @@ export function FavoriteRelaysProvider({ children }: { children: React.ReactNode useEffect(() => { if (!favoriteRelaysEvent) { - const favoriteRelays: string[] = DEFAULT_FAVORITE_RELAYS + const favoriteRelays: string[] = [] const storedRelaySets = storage.getRelaySets() storedRelaySets.forEach(({ relayUrls }) => { relayUrls.forEach((url) => { diff --git a/src/providers/FeedProvider.tsx b/src/providers/FeedProvider.tsx index 492d7445..b8cfe294 100644 --- a/src/providers/FeedProvider.tsx +++ b/src/providers/FeedProvider.tsx @@ -1,4 +1,3 @@ -import { DEFAULT_FAVORITE_RELAYS } from '@/constants' import { getRelaySetFromEvent } from '@/lib/event-metadata' import { isWebsocketUrl, normalizeUrl } from '@/lib/url' import indexedDb from '@/services/indexed-db.service' @@ -14,7 +13,7 @@ type TFeedContext = { relayUrls: string[] isReady: boolean switchFeed: ( - feedType: TFeedType, + feedType: TFeedType | null, options?: { activeRelaySetId?: string; pubkey?: string; relay?: string | null } ) => Promise } @@ -31,13 +30,10 @@ export const useFeed = () => { export function FeedProvider({ children }: { children: React.ReactNode }) { const { pubkey, isInitialized } = useNostr() - const { relaySets, favoriteRelays } = useFavoriteRelays() + const { relaySets } = useFavoriteRelays() const [relayUrls, setRelayUrls] = useState([]) const [isReady, setIsReady] = useState(false) - const [feedInfo, setFeedInfo] = useState({ - feedType: 'relay', - id: DEFAULT_FAVORITE_RELAYS[0] - }) + const [feedInfo, setFeedInfo] = useState(null) const feedInfoRef = useRef(feedInfo) useEffect(() => { @@ -46,10 +42,7 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { return } - let feedInfo: TFeedInfo = { - feedType: 'relay', - id: favoriteRelays[0] ?? DEFAULT_FAVORITE_RELAYS[0] - } + let feedInfo: TFeedInfo = null if (pubkey) { const storedFeedInfo = storage.getFeedInfo(pubkey) if (storedFeedInfo) { @@ -57,6 +50,10 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { } } + if (!feedInfo) { + return + } + if (feedInfo.feedType === 'relays') { return await switchFeed('relays', { activeRelaySetId: feedInfo.id }) } @@ -74,14 +71,27 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { init() }, [pubkey, isInitialized]) + useEffect(() => { + if (pubkey && !feedInfo) { + switchFeed('following', { pubkey }) + } + }, [pubkey, feedInfo]) + const switchFeed = async ( - feedType: TFeedType, + feedType: TFeedType | null, options: { activeRelaySetId?: string | null pubkey?: string | null relay?: string | null } = {} ) => { + if (!feedType) { + setFeedInfo(null) + feedInfoRef.current = null + setRelayUrls([]) + return + } + setIsReady(false) if (feedType === 'relay') { const normalizedUrl = normalizeUrl(options.relay ?? '') diff --git a/src/types/index.d.ts b/src/types/index.d.ts index bb91f332..3df6f8ae 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -107,7 +107,7 @@ export type TAccount = { export type TAccountPointer = Pick export type TFeedType = 'following' | 'relays' | 'relay' -export type TFeedInfo = { feedType: TFeedType; id?: string } +export type TFeedInfo = { feedType: TFeedType; id?: string } | null export type TLanguage = 'en' | 'zh' | 'pl'