From 20b4f2b1b2d8677a1a5413ec00e02fd23f03057f Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 18 Oct 2025 23:50:12 +0200 Subject: [PATCH] fix(explore): fetch nostrverse content when logged out - Allow exploring nostrverse writings and highlights without account - Default to nostrverse visibility when logged out - Update visibility settings when login state changes --- src/components/Explore.tsx | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/components/Explore.tsx b/src/components/Explore.tsx index 1b6069b6..5c303e5b 100644 --- a/src/components/Explore.tsx +++ b/src/components/Explore.tsx @@ -67,9 +67,9 @@ const Explore: React.FC = ({ relayPool, eventStore, settings, acti const cachedWritings = useStoreTimeline(eventStore, { kinds: [30023] }, toBlogPostPreview, []) - // Visibility filters (defaults from settings) + // Visibility filters (defaults from settings or nostrverse when logged out) const [visibility, setVisibility] = useState({ - nostrverse: settings?.defaultExploreScopeNostrverse ?? false, + nostrverse: activeAccount ? (settings?.defaultExploreScopeNostrverse ?? false) : true, friends: settings?.defaultExploreScopeFriends ?? true, mine: settings?.defaultExploreScopeMine ?? false }) @@ -84,6 +84,21 @@ const Explore: React.FC = ({ relayPool, eventStore, settings, acti } }, []) + // Update visibility when login state changes + useEffect(() => { + if (!activeAccount) { + // When logged out, show nostrverse by default + setVisibility(prev => ({ ...prev, nostrverse: true, friends: false, mine: false })) + } else { + // When logged in, use settings defaults + setVisibility({ + nostrverse: settings?.defaultExploreScopeNostrverse ?? false, + friends: settings?.defaultExploreScopeFriends ?? true, + mine: settings?.defaultExploreScopeMine ?? false + }) + } + }, [activeAccount, settings]) + // Update local state when prop changes useEffect(() => { if (propActiveTab) { @@ -93,15 +108,24 @@ const Explore: React.FC = ({ relayPool, eventStore, settings, acti useEffect(() => { const loadData = async () => { - if (!activeAccount) { - setLoading(false) - return - } - try { // show spinner but keep existing data setLoading(true) + // If not logged in, only fetch nostrverse content + if (!activeAccount) { + const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url) + const [nostrversePosts, nostriverseHighlights] = await Promise.all([ + fetchNostrverseBlogPosts(relayPool, relayUrls, 50, eventStore || undefined), + fetchNostrverseHighlights(relayPool, 100, eventStore || undefined) + ]) + + setBlogPosts(nostrversePosts) + setHighlights(nostriverseHighlights) + setLoading(false) + return + } + // Seed from in-memory cache if available to avoid empty flash const memoryCachedPosts = getCachedPosts(activeAccount.pubkey) if (memoryCachedPosts && memoryCachedPosts.length > 0) {