mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +01:00
fix: properly extract eventId from route params
- Add eventId to useParams instead of manually parsing pathname - useParams automatically extracts eventId from /e/:eventId route - Add debug logging to track event loading - This fixes the issue where eventId wasn't being passed to useEventLoader
This commit is contained in:
@@ -39,7 +39,7 @@ const Bookmarks: React.FC<BookmarksProps> = ({
|
||||
bookmarksLoading,
|
||||
onRefreshBookmarks
|
||||
}) => {
|
||||
const { naddr, npub } = useParams<{ naddr?: string; npub?: string }>()
|
||||
const { naddr, npub, eventId: eventIdParam } = useParams<{ naddr?: string; npub?: string; eventId?: string }>()
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const previousLocationRef = useRef<string>()
|
||||
@@ -56,8 +56,12 @@ const Bookmarks: React.FC<BookmarksProps> = ({
|
||||
const showMe = location.pathname.startsWith('/me')
|
||||
const showProfile = location.pathname.startsWith('/p/')
|
||||
const showSupport = location.pathname === '/support'
|
||||
const showEvent = location.pathname.startsWith('/e/')
|
||||
const eventId = showEvent ? location.pathname.slice(3) : undefined
|
||||
const eventId = eventIdParam
|
||||
|
||||
// Debug event loading
|
||||
if (eventId) {
|
||||
console.log('📍 Bookmarks: Event route detected. eventId:', eventId)
|
||||
}
|
||||
|
||||
// Extract tab from explore routes
|
||||
const exploreTab = location.pathname === '/explore/writings' ? 'writings' : 'highlights'
|
||||
|
||||
@@ -39,6 +39,7 @@ export function useEventLoader({
|
||||
useEffect(() => {
|
||||
if (!eventId) return
|
||||
|
||||
console.log('🔍 useEventLoader: Loading event:', eventId)
|
||||
setReaderLoading(true)
|
||||
setSelectedUrl('')
|
||||
setIsCollapsed(false)
|
||||
@@ -47,6 +48,7 @@ export function useEventLoader({
|
||||
if (eventStore) {
|
||||
const cachedEvent = eventStore.getEvent(eventId)
|
||||
if (cachedEvent) {
|
||||
console.log('✅ useEventLoader: Found cached event:', cachedEvent)
|
||||
displayEvent(cachedEvent)
|
||||
setReaderLoading(false)
|
||||
return
|
||||
@@ -55,21 +57,24 @@ export function useEventLoader({
|
||||
|
||||
// Otherwise fetch from relays
|
||||
if (!relayPool) {
|
||||
console.log('❌ useEventLoader: No relay pool available')
|
||||
setReaderLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
console.log('📡 useEventLoader: Fetching from relays...')
|
||||
const eventLoader = createEventLoader(relayPool, {
|
||||
eventStore: eventStore ?? undefined
|
||||
})
|
||||
|
||||
const subscription = eventLoader({ id: eventId }).subscribe({
|
||||
next: (event) => {
|
||||
console.log('✅ useEventLoader: Fetched event from relays:', event)
|
||||
displayEvent(event)
|
||||
setReaderLoading(false)
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error fetching event:', err)
|
||||
console.error('❌ useEventLoader: Error fetching event:', err)
|
||||
const errorContent: ReadableContent = {
|
||||
url: '',
|
||||
markdown: `Error loading event: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
||||
|
||||
Reference in New Issue
Block a user