fix: make event loading non-blocking and wait for relay pool

- Don't show error if relayPool isn't available yet
- Instead, keep loading state and wait for relayPool to become available
- Effect will re-run automatically when relayPool is set
- Enables smooth loading when navigating directly to /e/ URLs on page load
- Fetching happens in background without blocking user
This commit is contained in:
Gigi
2025-10-22 00:50:14 +02:00
parent b9d5e501f4
commit 479d9314bd

View File

@@ -68,15 +68,10 @@ export function useEventLoader({
setSelectedUrl('') // Don't set nostr: URL to avoid showing highlights
setIsCollapsed(false)
// Otherwise fetch from relays
// If no relay pool yet, wait for it or show a placeholder
if (!relayPool) {
const errorContent: ReadableContent = {
url: '',
html: `<div style="padding: 1rem; color: var(--color-error, red);">No relay pool available to fetch event</div>`,
title: 'Error'
}
setReaderContent(errorContent)
setReaderLoading(false)
// Show loading state until relayPool becomes available
// The effect will re-run once relayPool is set
return
}