mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 07:04:19 +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,
|
||||
className = 'bookmark-content'
|
||||
}) => {
|
||||
console.log('[RichContent] Rendering, content length:', content?.length || 0)
|
||||
console.log('[npub-resolve] RichContent: Rendering, content length:', content?.length || 0)
|
||||
|
||||
try {
|
||||
// Pattern to match:
|
||||
@@ -30,7 +30,7 @@ const RichContent: React.FC<RichContentProps> = ({
|
||||
const combinedPattern = new RegExp(`(${nostrPattern.source}|${urlPattern.source})`, 'gi')
|
||||
|
||||
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)
|
||||
const isNostrIdentifier = (str: string): boolean => {
|
||||
@@ -82,7 +82,7 @@ const RichContent: React.FC<RichContentProps> = ({
|
||||
</div>
|
||||
)
|
||||
} catch (err) {
|
||||
console.error('[RichContent] Error rendering:', err)
|
||||
console.error('[npub-resolve] RichContent: Error rendering:', err)
|
||||
return <div className={className}>Error rendering content</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ export const useMarkdownToHTML = (
|
||||
const [processedMarkdown, setProcessedMarkdown] = useState<string>('')
|
||||
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
|
||||
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
|
||||
useEffect(() => {
|
||||
@@ -71,8 +71,8 @@ export const useMarkdownToHTML = (
|
||||
let isCancelled = false
|
||||
|
||||
const processMarkdown = () => {
|
||||
console.log('[useMarkdownToHTML] Processing markdown, length:', markdown.length)
|
||||
console.log('[useMarkdownToHTML] Profile labels:', profileLabels.size, 'Article titles:', articleTitles.size)
|
||||
console.log('[npub-resolve] useMarkdownToHTML: Processing markdown, length:', markdown.length)
|
||||
console.log('[npub-resolve] useMarkdownToHTML: Profile labels:', profileLabels.size, 'Article titles:', articleTitles.size)
|
||||
try {
|
||||
// Replace nostr URIs with profile labels (progressive) and article titles
|
||||
const processed = replaceNostrUrisInMarkdownWithProfileLabels(
|
||||
@@ -80,13 +80,13 @@ export const useMarkdownToHTML = (
|
||||
profileLabels,
|
||||
articleTitles
|
||||
)
|
||||
console.log('[useMarkdownToHTML] Processed markdown length:', processed.length)
|
||||
console.log('[npub-resolve] useMarkdownToHTML: Processed markdown length:', processed.length)
|
||||
|
||||
if (isCancelled) return
|
||||
|
||||
setProcessedMarkdown(processed)
|
||||
} catch (err) {
|
||||
console.error('[useMarkdownToHTML] Error processing markdown:', err)
|
||||
console.error('[npub-resolve] useMarkdownToHTML: Error processing markdown:', err)
|
||||
if (!isCancelled) {
|
||||
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
|
||||
const profileData = useMemo(() => {
|
||||
console.log('[useProfileLabels] Processing content, length:', content?.length || 0)
|
||||
console.log('[npub-resolve] Processing content, length:', content?.length || 0)
|
||||
try {
|
||||
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')
|
||||
console.log('[useProfileLabels] Profile pointers:', filtered.length)
|
||||
console.log('[npub-resolve] Profile pointers:', filtered.length)
|
||||
const result: Array<{ pubkey: string; encoded: string }> = []
|
||||
filtered.forEach(pointer => {
|
||||
try {
|
||||
@@ -31,13 +31,13 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
||||
result.push({ pubkey, encoded: encoded as string })
|
||||
}
|
||||
} 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
|
||||
} catch (err) {
|
||||
console.error('[useProfileLabels] Error extracting pointers:', err)
|
||||
console.error('[npub-resolve] Error extracting pointers:', err)
|
||||
return []
|
||||
}
|
||||
}, [content])
|
||||
@@ -46,7 +46,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
||||
|
||||
// Build initial labels from eventStore, then fetch missing profiles
|
||||
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
|
||||
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
|
||||
if (displayName) {
|
||||
labels.set(encoded, `@${displayName}`)
|
||||
console.log('[useProfileLabels] Found in eventStore:', encoded, '->', displayName)
|
||||
console.log('[npub-resolve] Found in eventStore:', encoded, '->', displayName)
|
||||
} else {
|
||||
pubkeysToFetch.push(pubkey)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
||||
|
||||
// Fetch missing profiles asynchronously
|
||||
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)
|
||||
.then(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
|
||||
if (displayName) {
|
||||
updatedLabels.set(encoded, `@${displayName}`)
|
||||
console.log('[useProfileLabels] Fetched profile:', encoded, '->', displayName)
|
||||
console.log('[npub-resolve] Fetched profile:', encoded, '->', displayName)
|
||||
}
|
||||
} catch {
|
||||
// ignore parse errors
|
||||
@@ -106,12 +106,12 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
||||
setProfileLabels(updatedLabels)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('[useProfileLabels] Error fetching profiles:', err)
|
||||
console.error('[npub-resolve] Error fetching profiles:', err)
|
||||
})
|
||||
}
|
||||
}, [profileData, eventStore, relayPool])
|
||||
|
||||
console.log('[useProfileLabels] Final labels map size:', profileLabels.size)
|
||||
console.log('[npub-resolve] Final labels map size:', profileLabels.size)
|
||||
return profileLabels
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ const NOSTR_URI_REGEX = Tokens.nostrLink
|
||||
* Extract all nostr URIs from text using applesauce helpers
|
||||
*/
|
||||
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 {
|
||||
const pointers = getContentPointers(text)
|
||||
console.log('[nostrUriResolver] Found pointers:', pointers.length)
|
||||
console.log('[npub-resolve] extractNostrUris: Found pointers:', pointers.length)
|
||||
const result: string[] = []
|
||||
pointers.forEach(pointer => {
|
||||
try {
|
||||
@@ -28,13 +28,13 @@ export function extractNostrUris(text: string): string[] {
|
||||
result.push(encoded)
|
||||
}
|
||||
} 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
|
||||
} catch (err) {
|
||||
console.error('[nostrUriResolver] Error in extractNostrUris:', err)
|
||||
console.error('[npub-resolve] extractNostrUris: Error:', err)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user