mirror of
https://github.com/dergigi/boris.git
synced 2026-02-23 07:54:59 +01:00
fix: add hydrated bookmark events to global eventStore
- bookmarkController now accepts eventStore in start() options - All hydrated events (both by ID and by coordinates) are added to the external eventStore - This makes hydrated bookmark events available to useEventLoader and other hooks - Fixes issue where /e/ path couldn't find events because they weren't in the global eventStore - Now instant loading works for all bookmarked events
This commit is contained in:
@@ -95,7 +95,7 @@ function AppRoutes({
|
||||
|
||||
// Load bookmarks
|
||||
if (bookmarks.length === 0 && !bookmarksLoading) {
|
||||
bookmarkController.start({ relayPool, activeAccount, accountManager })
|
||||
bookmarkController.start({ relayPool, activeAccount, accountManager, eventStore: eventStore || undefined })
|
||||
}
|
||||
|
||||
// Load contacts
|
||||
|
||||
@@ -25,6 +25,7 @@ export function useEventLoader({
|
||||
setIsCollapsed
|
||||
}: UseEventLoaderProps) {
|
||||
const displayEvent = useCallback((event: NostrEvent) => {
|
||||
console.log('🎨 displayEvent: Creating ReadableContent from event')
|
||||
// Format event metadata as HTML header
|
||||
const metaHtml = `<div style="opacity: 0.6; font-size: 0.9em; margin-bottom: 1rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem;">
|
||||
<div>Event ID: <code>${event.id.slice(0, 16)}...</code></div>
|
||||
@@ -44,6 +45,7 @@ export function useEventLoader({
|
||||
html: metaHtml + `<div style="white-space: pre-wrap; word-break: break-word;">${escapedContent}</div>`,
|
||||
title: `Note (${event.kind})`
|
||||
}
|
||||
console.log('🎨 displayEvent: Setting readerContent with html:', { title: content.title, htmlLength: content.html?.length })
|
||||
setReaderContent(content)
|
||||
}, [setReaderContent])
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ class BookmarkController {
|
||||
private eventStore = new EventStore()
|
||||
private eventLoader: ReturnType<typeof createEventLoader> | null = null
|
||||
private addressLoader: ReturnType<typeof createAddressLoader> | null = null
|
||||
private externalEventStore: EventStore | null = null
|
||||
|
||||
onRawEvent(cb: RawEventCallback): () => void {
|
||||
this.rawEventListeners.push(cb)
|
||||
@@ -157,6 +158,11 @@ class BookmarkController {
|
||||
idToEvent.set(coordinate, event)
|
||||
}
|
||||
|
||||
// Add to external event store if available
|
||||
if (this.externalEventStore) {
|
||||
this.externalEventStore.add(event)
|
||||
}
|
||||
|
||||
onProgress()
|
||||
},
|
||||
error: () => {
|
||||
@@ -200,6 +206,11 @@ class BookmarkController {
|
||||
idToEvent.set(coordinate, event)
|
||||
idToEvent.set(event.id, event)
|
||||
|
||||
// Add to external event store if available
|
||||
if (this.externalEventStore) {
|
||||
this.externalEventStore.add(event)
|
||||
}
|
||||
|
||||
onProgress()
|
||||
},
|
||||
error: () => {
|
||||
@@ -337,8 +348,12 @@ class BookmarkController {
|
||||
relayPool: RelayPool
|
||||
activeAccount: unknown
|
||||
accountManager: { getActive: () => unknown }
|
||||
eventStore?: EventStore
|
||||
}): Promise<void> {
|
||||
const { relayPool, activeAccount, accountManager } = options
|
||||
const { relayPool, activeAccount, accountManager, eventStore } = options
|
||||
|
||||
// Store the external event store reference for adding hydrated events
|
||||
this.externalEventStore = eventStore || null
|
||||
|
||||
if (!activeAccount || typeof (activeAccount as { pubkey?: string }).pubkey !== 'string') {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user