diff --git a/src/components/NostrMentionLink.tsx b/src/components/NostrMentionLink.tsx index 1c2a83af..f7788f56 100644 --- a/src/components/NostrMentionLink.tsx +++ b/src/components/NostrMentionLink.tsx @@ -46,14 +46,14 @@ const NostrMentionLink: React.FC = ({ // Check cache const cached = loadCachedProfiles([pubkey]) if (cached.has(pubkey)) { - console.log(`[nostr-mention-link] ${nostrUri.slice(0, 30)}... in cache`) + console.log(`[profile-loading-debug][nostr-mention-link] ${nostrUri.slice(0, 30)}... in cache`) return true } // Check eventStore const eventStoreProfile = eventStore?.getEvent(pubkey + ':0') const inStore = !!eventStoreProfile if (inStore) { - console.log(`[nostr-mention-link] ${nostrUri.slice(0, 30)}... in eventStore`) + console.log(`[profile-loading-debug][nostr-mention-link] ${nostrUri.slice(0, 30)}... in eventStore`) } return inStore }, [pubkey, eventStore, nostrUri]) @@ -62,7 +62,7 @@ const NostrMentionLink: React.FC = ({ const isLoading = !profile && pubkey && !isInCacheOrStore && decoded && (decoded.type === 'npub' || decoded.type === 'nprofile') if (isLoading) { - console.log(`[nostr-mention-link] ${nostrUri.slice(0, 30)}... isLoading=true (profile=${!!profile}, pubkey=${!!pubkey}, inCacheOrStore=${isInCacheOrStore})`) + console.log(`[profile-loading-debug][nostr-mention-link] ${nostrUri.slice(0, 30)}... isLoading=true (profile=${!!profile}, pubkey=${!!pubkey}, inCacheOrStore=${isInCacheOrStore})`) } // If decoding failed, show shortened identifier diff --git a/src/components/ResolvedMention.tsx b/src/components/ResolvedMention.tsx index bf5d7481..d8fee2b3 100644 --- a/src/components/ResolvedMention.tsx +++ b/src/components/ResolvedMention.tsx @@ -31,14 +31,14 @@ const ResolvedMention: React.FC = ({ encoded }) => { // Check cache const cached = loadCachedProfiles([pubkey]) if (cached.has(pubkey)) { - console.log(`[resolved-mention] ${encoded?.slice(0, 16)}... in cache`) + console.log(`[profile-loading-debug][resolved-mention] ${encoded?.slice(0, 16)}... in cache`) return true } // Check eventStore const eventStoreProfile = eventStore?.getEvent(pubkey + ':0') const inStore = !!eventStoreProfile if (inStore) { - console.log(`[resolved-mention] ${encoded?.slice(0, 16)}... in eventStore`) + console.log(`[profile-loading-debug][resolved-mention] ${encoded?.slice(0, 16)}... in eventStore`) } return inStore }, [pubkey, eventStore, encoded]) @@ -46,7 +46,7 @@ const ResolvedMention: React.FC = ({ encoded }) => { // Show loading if profile doesn't exist and not in cache/store const isLoading = !profile && pubkey && !isInCacheOrStore if (isLoading && encoded) { - console.log(`[resolved-mention] ${encoded.slice(0, 16)}... isLoading=true (profile=${!!profile}, pubkey=${!!pubkey}, inCacheOrStore=${isInCacheOrStore})`) + console.log(`[profile-loading-debug][resolved-mention] ${encoded.slice(0, 16)}... isLoading=true (profile=${!!profile}, pubkey=${!!pubkey}, inCacheOrStore=${isInCacheOrStore})`) } const display = pubkey ? getProfileDisplayName(profile, pubkey) : encoded diff --git a/src/hooks/useArticleLoader.ts b/src/hooks/useArticleLoader.ts index bba59af4..a5e090d3 100644 --- a/src/hooks/useArticleLoader.ts +++ b/src/hooks/useArticleLoader.ts @@ -264,10 +264,10 @@ export function useArticleLoader({ const loadArticle = async () => { const requestId = ++currentRequestIdRef.current - console.log(`[article-loader] Starting loadArticle requestId=${requestId} for naddr=${naddr.slice(0, 20)}...`) + console.log(`[profile-loading-debug][article-loader] Starting loadArticle requestId=${requestId} for naddr=${naddr.slice(0, 20)}...`) if (!mountedRef.current) { - console.log(`[article-loader] Aborted loadArticle requestId=${requestId} - not mounted`) + console.log(`[profile-loading-debug][article-loader] Aborted loadArticle requestId=${requestId} - not mounted`) return } @@ -284,7 +284,7 @@ export function useArticleLoader({ // At this point, we've checked EventStore and cache - neither had content // Only show loading skeleton if we also don't have preview data if (previewData) { - console.log(`[article-loader] requestId=${requestId} has previewData, showing immediately`) + console.log(`[profile-loading-debug][article-loader] requestId=${requestId} has previewData, showing immediately`) // If we have preview data from navigation, show it immediately (no skeleton!) setCurrentTitle(previewData.title) setReaderContent({ @@ -301,7 +301,7 @@ export function useArticleLoader({ // Preloading again would be redundant and could cause unnecessary network requests } else { // No cache, no EventStore, no preview data - need to load from relays - console.log(`[article-loader] requestId=${requestId} no previewData, setting loading=true, content=undefined`) + console.log(`[profile-loading-debug][article-loader] requestId=${requestId} no previewData, setting loading=true, content=undefined`) setReaderLoading(true) setReaderContent(undefined) } diff --git a/src/hooks/useMarkdownToHTML.ts b/src/hooks/useMarkdownToHTML.ts index 56b4d56f..b9e9d0d0 100644 --- a/src/hooks/useMarkdownToHTML.ts +++ b/src/hooks/useMarkdownToHTML.ts @@ -56,8 +56,8 @@ export const useMarkdownToHTML = ( // Process markdown with progressive profile labels and article titles useEffect(() => { - console.log(`[markdown-to-html] Processing markdown, profileLabels=${profileLabels.size}, profileLoading=${profileLoading.size}, articleTitles=${articleTitles.size}`) - console.log(`[markdown-to-html] Clearing rendered HTML and processed markdown`) + console.log(`[profile-loading-debug][markdown-to-html] Processing markdown, profileLabels=${profileLabels.size}, profileLoading=${profileLoading.size}, articleTitles=${articleTitles.size}`) + console.log(`[profile-loading-debug][markdown-to-html] Clearing rendered HTML and processed markdown`) // Always clear previous render immediately to avoid showing stale content while processing setRenderedHtml('') setProcessedMarkdown('') @@ -80,7 +80,7 @@ export const useMarkdownToHTML = ( if (isCancelled) return - console.log(`[markdown-to-html] Processed markdown, loading states:`, Array.from(profileLoading.entries()).filter(([, l]) => l).map(([e]) => e.slice(0, 16) + '...')) + console.log(`[profile-loading-debug][markdown-to-html] Processed markdown, loading states:`, Array.from(profileLoading.entries()).filter(([, l]) => l).map(([e]) => e.slice(0, 16) + '...')) setProcessedMarkdown(processed) } catch (error) { console.error(`[markdown-to-html] Error processing markdown:`, error) diff --git a/src/hooks/useProfileLabels.ts b/src/hooks/useProfileLabels.ts index 0a574ab5..64cb2ea5 100644 --- a/src/hooks/useProfileLabels.ts +++ b/src/hooks/useProfileLabels.ts @@ -207,7 +207,7 @@ export function useProfileLabels( // Skip if already resolved from initial cache if (labels.has(encoded)) { loading.set(encoded, false) - console.log(`[profile-labels-loading] ${encoded.slice(0, 16)}... in cache, not loading`) + console.log(`[profile-loading-debug][profile-labels-loading] ${encoded.slice(0, 16)}... in cache, not loading`) return } @@ -227,14 +227,14 @@ export function useProfileLabels( labels.set(encoded, fallback) } loading.set(encoded, false) - console.log(`[profile-labels-loading] ${encoded.slice(0, 16)}... in eventStore, not loading`) + console.log(`[profile-loading-debug][profile-labels-loading] ${encoded.slice(0, 16)}... in eventStore, not loading`) } else { // No profile found yet, will use fallback after fetch or keep empty // We'll set fallback labels for missing profiles at the end // Mark as loading since we'll fetch it pubkeysToFetch.push(pubkey) loading.set(encoded, true) - console.log(`[profile-labels-loading] ${encoded.slice(0, 16)}... not found, SET LOADING=true`) + console.log(`[profile-loading-debug][profile-labels-loading] ${encoded.slice(0, 16)}... not found, SET LOADING=true`) } }) @@ -248,11 +248,11 @@ export function useProfileLabels( setProfileLabels(new Map(labels)) setProfileLoading(new Map(loading)) - console.log(`[profile-labels-loading] Initial loading state:`, Array.from(loading.entries()).map(([e, l]) => `${e.slice(0, 16)}...=${l}`)) + console.log(`[profile-loading-debug][profile-labels-loading] Initial loading state:`, Array.from(loading.entries()).map(([e, l]) => `${e.slice(0, 16)}...=${l}`)) // Fetch missing profiles asynchronously with reactive updates if (pubkeysToFetch.length > 0 && relayPool && eventStore) { - console.log(`[profile-labels-loading] Starting fetch for ${pubkeysToFetch.length} profiles:`, pubkeysToFetch.map(p => p.slice(0, 16) + '...')) + console.log(`[profile-loading-debug][profile-labels-loading] Starting fetch for ${pubkeysToFetch.length} profiles:`, pubkeysToFetch.map(p => p.slice(0, 16) + '...')) const pubkeysToFetchSet = new Set(pubkeysToFetch) // Create a map from pubkey to encoded identifier for quick lookup const pubkeyToEncoded = new Map() @@ -279,7 +279,7 @@ export function useProfileLabels( scheduleBatchedUpdate() // Clear loading state for this profile when it resolves - console.log(`[profile-labels-loading] Profile resolved for ${encoded.slice(0, 16)}..., CLEARING LOADING`) + console.log(`[profile-loading-debug][profile-labels-loading] Profile resolved for ${encoded.slice(0, 16)}..., CLEARING LOADING`) setProfileLoading(prevLoading => { const updated = new Map(prevLoading) updated.set(encoded, false) @@ -294,7 +294,7 @@ export function useProfileLabels( applyPendingUpdates() // Clear loading state for all fetched profiles - console.log(`[profile-labels-loading] Fetch complete, clearing loading for all ${pubkeysToFetch.length} profiles`) + console.log(`[profile-loading-debug][profile-labels-loading] Fetch complete, clearing loading for all ${pubkeysToFetch.length} profiles`) setProfileLoading(prevLoading => { const updated = new Map(prevLoading) pubkeysToFetch.forEach(pubkey => { @@ -303,7 +303,7 @@ export function useProfileLabels( const wasLoading = updated.get(encoded) updated.set(encoded, false) if (wasLoading) { - console.log(`[profile-labels-loading] ${encoded.slice(0, 16)}... CLEARED loading after fetch complete`) + console.log(`[profile-loading-debug][profile-labels-loading] ${encoded.slice(0, 16)}... CLEARED loading after fetch complete`) } } }) diff --git a/src/utils/nostrUriResolver.tsx b/src/utils/nostrUriResolver.tsx index c41d5db5..3938220d 100644 --- a/src/utils/nostrUriResolver.tsx +++ b/src/utils/nostrUriResolver.tsx @@ -340,7 +340,7 @@ export function replaceNostrUrisInMarkdownWithProfileLabels( // For npub/nprofile, check if loading and show loading state if ((decoded.type === 'npub' || decoded.type === 'nprofile') && profileLoading.has(encoded) && profileLoading.get(encoded)) { const label = getNostrUriLabel(encoded) - console.log(`[nostr-uri-resolve] ${encoded.slice(0, 16)}... is LOADING, showing loading state`) + console.log(`[profile-loading-debug][nostr-uri-resolve] ${encoded.slice(0, 16)}... is LOADING, showing loading state`) // Wrap in span with profile-loading class for CSS styling return `[${label}](${link})` }