mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 23:24:22 +01:00
debug: standardize all npub resolution debug logs with [npub-resolve] prefix
This commit is contained in:
@@ -19,7 +19,7 @@ const RichContent: React.FC<RichContentProps> = ({
|
|||||||
content,
|
content,
|
||||||
className = 'bookmark-content'
|
className = 'bookmark-content'
|
||||||
}) => {
|
}) => {
|
||||||
console.log('[RichContent] Rendering, content length:', content?.length || 0)
|
console.log('[npub-resolve] RichContent: Rendering, content length:', content?.length || 0)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Pattern to match:
|
// Pattern to match:
|
||||||
@@ -30,7 +30,7 @@ const RichContent: React.FC<RichContentProps> = ({
|
|||||||
const combinedPattern = new RegExp(`(${nostrPattern.source}|${urlPattern.source})`, 'gi')
|
const combinedPattern = new RegExp(`(${nostrPattern.source}|${urlPattern.source})`, 'gi')
|
||||||
|
|
||||||
const parts = content.split(combinedPattern)
|
const parts = content.split(combinedPattern)
|
||||||
console.log('[RichContent] Split into parts:', parts.length)
|
console.log('[npub-resolve] RichContent: Split into parts:', parts.length)
|
||||||
|
|
||||||
// Helper to check if a string is a nostr identifier (without mutating regex state)
|
// Helper to check if a string is a nostr identifier (without mutating regex state)
|
||||||
const isNostrIdentifier = (str: string): boolean => {
|
const isNostrIdentifier = (str: string): boolean => {
|
||||||
@@ -82,7 +82,7 @@ const RichContent: React.FC<RichContentProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[RichContent] Error rendering:', err)
|
console.error('[npub-resolve] RichContent: Error rendering:', err)
|
||||||
return <div className={className}>Error rendering content</div>
|
return <div className={className}>Error rendering content</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ export const useMarkdownToHTML = (
|
|||||||
const [processedMarkdown, setProcessedMarkdown] = useState<string>('')
|
const [processedMarkdown, setProcessedMarkdown] = useState<string>('')
|
||||||
const [articleTitles, setArticleTitles] = useState<Map<string, string>>(new Map())
|
const [articleTitles, setArticleTitles] = useState<Map<string, string>>(new Map())
|
||||||
|
|
||||||
console.log('[useMarkdownToHTML] Hook called, markdown length:', markdown?.length || 0, 'hasRelayPool:', !!relayPool)
|
console.log('[npub-resolve] useMarkdownToHTML: markdown length:', markdown?.length || 0, 'hasRelayPool:', !!relayPool)
|
||||||
|
|
||||||
// Resolve profile labels progressively as profiles load
|
// Resolve profile labels progressively as profiles load
|
||||||
const profileLabels = useProfileLabels(markdown || '', relayPool)
|
const profileLabels = useProfileLabels(markdown || '', relayPool)
|
||||||
console.log('[useMarkdownToHTML] Profile labels size:', profileLabels.size)
|
console.log('[npub-resolve] useMarkdownToHTML: Profile labels size:', profileLabels.size)
|
||||||
|
|
||||||
// Fetch article titles
|
// Fetch article titles
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -71,8 +71,8 @@ export const useMarkdownToHTML = (
|
|||||||
let isCancelled = false
|
let isCancelled = false
|
||||||
|
|
||||||
const processMarkdown = () => {
|
const processMarkdown = () => {
|
||||||
console.log('[useMarkdownToHTML] Processing markdown, length:', markdown.length)
|
console.log('[npub-resolve] useMarkdownToHTML: Processing markdown, length:', markdown.length)
|
||||||
console.log('[useMarkdownToHTML] Profile labels:', profileLabels.size, 'Article titles:', articleTitles.size)
|
console.log('[npub-resolve] useMarkdownToHTML: Profile labels:', profileLabels.size, 'Article titles:', articleTitles.size)
|
||||||
try {
|
try {
|
||||||
// Replace nostr URIs with profile labels (progressive) and article titles
|
// Replace nostr URIs with profile labels (progressive) and article titles
|
||||||
const processed = replaceNostrUrisInMarkdownWithProfileLabels(
|
const processed = replaceNostrUrisInMarkdownWithProfileLabels(
|
||||||
@@ -80,13 +80,13 @@ export const useMarkdownToHTML = (
|
|||||||
profileLabels,
|
profileLabels,
|
||||||
articleTitles
|
articleTitles
|
||||||
)
|
)
|
||||||
console.log('[useMarkdownToHTML] Processed markdown length:', processed.length)
|
console.log('[npub-resolve] useMarkdownToHTML: Processed markdown length:', processed.length)
|
||||||
|
|
||||||
if (isCancelled) return
|
if (isCancelled) return
|
||||||
|
|
||||||
setProcessedMarkdown(processed)
|
setProcessedMarkdown(processed)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[useMarkdownToHTML] Error processing markdown:', err)
|
console.error('[npub-resolve] useMarkdownToHTML: Error processing markdown:', err)
|
||||||
if (!isCancelled) {
|
if (!isCancelled) {
|
||||||
setProcessedMarkdown(markdown) // Fallback to original
|
setProcessedMarkdown(markdown) // Fallback to original
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
|
|
||||||
// Extract profile pointers (npub and nprofile) using applesauce helpers
|
// Extract profile pointers (npub and nprofile) using applesauce helpers
|
||||||
const profileData = useMemo(() => {
|
const profileData = useMemo(() => {
|
||||||
console.log('[useProfileLabels] Processing content, length:', content?.length || 0)
|
console.log('[npub-resolve] Processing content, length:', content?.length || 0)
|
||||||
try {
|
try {
|
||||||
const pointers = getContentPointers(content)
|
const pointers = getContentPointers(content)
|
||||||
console.log('[useProfileLabels] Found pointers:', pointers.length, 'types:', pointers.map(p => p.type))
|
console.log('[npub-resolve] Found pointers:', pointers.length, 'types:', pointers.map(p => p.type))
|
||||||
const filtered = pointers.filter(p => p.type === 'npub' || p.type === 'nprofile')
|
const filtered = pointers.filter(p => p.type === 'npub' || p.type === 'nprofile')
|
||||||
console.log('[useProfileLabels] Profile pointers:', filtered.length)
|
console.log('[npub-resolve] Profile pointers:', filtered.length)
|
||||||
const result: Array<{ pubkey: string; encoded: string }> = []
|
const result: Array<{ pubkey: string; encoded: string }> = []
|
||||||
filtered.forEach(pointer => {
|
filtered.forEach(pointer => {
|
||||||
try {
|
try {
|
||||||
@@ -31,13 +31,13 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
result.push({ pubkey, encoded: encoded as string })
|
result.push({ pubkey, encoded: encoded as string })
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[useProfileLabels] Error processing pointer:', err, pointer)
|
console.error('[npub-resolve] Error processing pointer:', err, pointer)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('[useProfileLabels] Profile data after filtering:', result.length)
|
console.log('[npub-resolve] Profile data after filtering:', result.length)
|
||||||
return result
|
return result
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[useProfileLabels] Error extracting pointers:', err)
|
console.error('[npub-resolve] Error extracting pointers:', err)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}, [content])
|
}, [content])
|
||||||
@@ -46,7 +46,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
|
|
||||||
// Build initial labels from eventStore, then fetch missing profiles
|
// Build initial labels from eventStore, then fetch missing profiles
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('[useProfileLabels] Building labels, profileData:', profileData.length, 'hasEventStore:', !!eventStore)
|
console.log('[npub-resolve] Building labels, profileData:', profileData.length, 'hasEventStore:', !!eventStore)
|
||||||
|
|
||||||
// First, get profiles from eventStore synchronously
|
// First, get profiles from eventStore synchronously
|
||||||
const labels = new Map<string, string>()
|
const labels = new Map<string, string>()
|
||||||
@@ -61,7 +61,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
labels.set(encoded, `@${displayName}`)
|
labels.set(encoded, `@${displayName}`)
|
||||||
console.log('[useProfileLabels] Found in eventStore:', encoded, '->', displayName)
|
console.log('[npub-resolve] Found in eventStore:', encoded, '->', displayName)
|
||||||
} else {
|
} else {
|
||||||
pubkeysToFetch.push(pubkey)
|
pubkeysToFetch.push(pubkey)
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
|
|
||||||
// Fetch missing profiles asynchronously
|
// Fetch missing profiles asynchronously
|
||||||
if (pubkeysToFetch.length > 0 && relayPool && eventStore) {
|
if (pubkeysToFetch.length > 0 && relayPool && eventStore) {
|
||||||
console.log('[useProfileLabels] Fetching', pubkeysToFetch.length, 'missing profiles')
|
console.log('[npub-resolve] Fetching', pubkeysToFetch.length, 'missing profiles')
|
||||||
fetchProfiles(relayPool, eventStore as unknown as IEventStore, pubkeysToFetch)
|
fetchProfiles(relayPool, eventStore as unknown as IEventStore, pubkeysToFetch)
|
||||||
.then(profiles => {
|
.then(profiles => {
|
||||||
// Rebuild labels map with fetched profiles
|
// Rebuild labels map with fetched profiles
|
||||||
@@ -95,7 +95,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
updatedLabels.set(encoded, `@${displayName}`)
|
updatedLabels.set(encoded, `@${displayName}`)
|
||||||
console.log('[useProfileLabels] Fetched profile:', encoded, '->', displayName)
|
console.log('[npub-resolve] Fetched profile:', encoded, '->', displayName)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore parse errors
|
// ignore parse errors
|
||||||
@@ -106,12 +106,12 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
setProfileLabels(updatedLabels)
|
setProfileLabels(updatedLabels)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('[useProfileLabels] Error fetching profiles:', err)
|
console.error('[npub-resolve] Error fetching profiles:', err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [profileData, eventStore, relayPool])
|
}, [profileData, eventStore, relayPool])
|
||||||
|
|
||||||
console.log('[useProfileLabels] Final labels map size:', profileLabels.size)
|
console.log('[npub-resolve] Final labels map size:', profileLabels.size)
|
||||||
return profileLabels
|
return profileLabels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ const NOSTR_URI_REGEX = Tokens.nostrLink
|
|||||||
* Extract all nostr URIs from text using applesauce helpers
|
* Extract all nostr URIs from text using applesauce helpers
|
||||||
*/
|
*/
|
||||||
export function extractNostrUris(text: string): string[] {
|
export function extractNostrUris(text: string): string[] {
|
||||||
console.log('[nostrUriResolver] extractNostrUris called, text length:', text?.length || 0)
|
console.log('[npub-resolve] extractNostrUris: text length:', text?.length || 0)
|
||||||
try {
|
try {
|
||||||
const pointers = getContentPointers(text)
|
const pointers = getContentPointers(text)
|
||||||
console.log('[nostrUriResolver] Found pointers:', pointers.length)
|
console.log('[npub-resolve] extractNostrUris: Found pointers:', pointers.length)
|
||||||
const result: string[] = []
|
const result: string[] = []
|
||||||
pointers.forEach(pointer => {
|
pointers.forEach(pointer => {
|
||||||
try {
|
try {
|
||||||
@@ -28,13 +28,13 @@ export function extractNostrUris(text: string): string[] {
|
|||||||
result.push(encoded)
|
result.push(encoded)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[nostrUriResolver] Error encoding pointer:', err, pointer)
|
console.error('[npub-resolve] extractNostrUris: Error encoding pointer:', err, pointer)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('[nostrUriResolver] Extracted URIs:', result.length)
|
console.log('[npub-resolve] extractNostrUris: Extracted URIs:', result.length)
|
||||||
return result
|
return result
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[nostrUriResolver] Error in extractNostrUris:', err)
|
console.error('[npub-resolve] extractNostrUris: Error:', err)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user