mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 07:04:19 +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,
|
bookmarksLoading,
|
||||||
onRefreshBookmarks
|
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 location = useLocation()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const previousLocationRef = useRef<string>()
|
const previousLocationRef = useRef<string>()
|
||||||
@@ -56,8 +56,12 @@ const Bookmarks: React.FC<BookmarksProps> = ({
|
|||||||
const showMe = location.pathname.startsWith('/me')
|
const showMe = location.pathname.startsWith('/me')
|
||||||
const showProfile = location.pathname.startsWith('/p/')
|
const showProfile = location.pathname.startsWith('/p/')
|
||||||
const showSupport = location.pathname === '/support'
|
const showSupport = location.pathname === '/support'
|
||||||
const showEvent = location.pathname.startsWith('/e/')
|
const eventId = eventIdParam
|
||||||
const eventId = showEvent ? location.pathname.slice(3) : undefined
|
|
||||||
|
// Debug event loading
|
||||||
|
if (eventId) {
|
||||||
|
console.log('📍 Bookmarks: Event route detected. eventId:', eventId)
|
||||||
|
}
|
||||||
|
|
||||||
// Extract tab from explore routes
|
// Extract tab from explore routes
|
||||||
const exploreTab = location.pathname === '/explore/writings' ? 'writings' : 'highlights'
|
const exploreTab = location.pathname === '/explore/writings' ? 'writings' : 'highlights'
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export function useEventLoader({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!eventId) return
|
if (!eventId) return
|
||||||
|
|
||||||
|
console.log('🔍 useEventLoader: Loading event:', eventId)
|
||||||
setReaderLoading(true)
|
setReaderLoading(true)
|
||||||
setSelectedUrl('')
|
setSelectedUrl('')
|
||||||
setIsCollapsed(false)
|
setIsCollapsed(false)
|
||||||
@@ -47,6 +48,7 @@ export function useEventLoader({
|
|||||||
if (eventStore) {
|
if (eventStore) {
|
||||||
const cachedEvent = eventStore.getEvent(eventId)
|
const cachedEvent = eventStore.getEvent(eventId)
|
||||||
if (cachedEvent) {
|
if (cachedEvent) {
|
||||||
|
console.log('✅ useEventLoader: Found cached event:', cachedEvent)
|
||||||
displayEvent(cachedEvent)
|
displayEvent(cachedEvent)
|
||||||
setReaderLoading(false)
|
setReaderLoading(false)
|
||||||
return
|
return
|
||||||
@@ -55,21 +57,24 @@ export function useEventLoader({
|
|||||||
|
|
||||||
// Otherwise fetch from relays
|
// Otherwise fetch from relays
|
||||||
if (!relayPool) {
|
if (!relayPool) {
|
||||||
|
console.log('❌ useEventLoader: No relay pool available')
|
||||||
setReaderLoading(false)
|
setReaderLoading(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('📡 useEventLoader: Fetching from relays...')
|
||||||
const eventLoader = createEventLoader(relayPool, {
|
const eventLoader = createEventLoader(relayPool, {
|
||||||
eventStore: eventStore ?? undefined
|
eventStore: eventStore ?? undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
const subscription = eventLoader({ id: eventId }).subscribe({
|
const subscription = eventLoader({ id: eventId }).subscribe({
|
||||||
next: (event) => {
|
next: (event) => {
|
||||||
|
console.log('✅ useEventLoader: Fetched event from relays:', event)
|
||||||
displayEvent(event)
|
displayEvent(event)
|
||||||
setReaderLoading(false)
|
setReaderLoading(false)
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.error('Error fetching event:', err)
|
console.error('❌ useEventLoader: Error fetching event:', err)
|
||||||
const errorContent: ReadableContent = {
|
const errorContent: ReadableContent = {
|
||||||
url: '',
|
url: '',
|
||||||
markdown: `Error loading event: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
markdown: `Error loading event: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user