diff --git a/src/hooks/useMarkdownToHTML.ts b/src/hooks/useMarkdownToHTML.ts
index 84564977..b8320a01 100644
--- a/src/hooks/useMarkdownToHTML.ts
+++ b/src/hooks/useMarkdownToHTML.ts
@@ -27,7 +27,12 @@ export const useMarkdownToHTML = (
// Create stable dependencies based on Map contents, not Map objects
// This prevents unnecessary reprocessing when Maps are recreated with same content
const profileLabelsKey = useMemo(() => {
- return Array.from(profileLabels.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join('|')
+ const key = Array.from(profileLabels.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join('|')
+ console.log(`[shimmer-debug][markdown-to-html] profileLabelsKey computed, profileLabels.size=${profileLabels.size}, key length=${key.length}`)
+ if (profileLabels.size > 0) {
+ console.log(`[shimmer-debug][markdown-to-html] Profile labels in key:`, Array.from(profileLabels.entries()).slice(0, 3).map(([k, v]) => `${k.slice(0, 16)}...="${v}"`))
+ }
+ return key
}, [profileLabels])
const profileLoadingKey = useMemo(() => {
diff --git a/src/hooks/useProfileLabels.ts b/src/hooks/useProfileLabels.ts
index 2983a043..300aefc4 100644
--- a/src/hooks/useProfileLabels.ts
+++ b/src/hooks/useProfileLabels.ts
@@ -89,7 +89,11 @@ export function useProfileLabels(
*/
const applyPendingUpdates = () => {
const pendingUpdates = pendingUpdatesRef.current
- if (pendingUpdates.size === 0) return
+ console.log(`[shimmer-debug][profile-labels] applyPendingUpdates called, pendingUpdates.size=${pendingUpdates.size}`)
+ if (pendingUpdates.size === 0) {
+ console.log(`[shimmer-debug][profile-labels] No pending updates to apply`)
+ return
+ }
// Cancel scheduled RAF since we're applying synchronously
if (rafScheduledRef.current !== null) {
@@ -100,9 +104,13 @@ export function useProfileLabels(
// Apply all pending updates in one batch
setProfileLabels(prevLabels => {
const updatedLabels = new Map(prevLabels)
- for (const [encoded, label] of pendingUpdates.entries()) {
- updatedLabels.set(encoded, label)
+ const updatesList: string[] = []
+ for (const [pubkey, label] of pendingUpdates.entries()) {
+ updatedLabels.set(pubkey, label)
+ updatesList.push(`${pubkey.slice(0, 16)}...="${label}"`)
}
+ console.log(`[shimmer-debug][profile-labels] Applying ${updatesList.length} pending updates:`, updatesList)
+ console.log(`[shimmer-debug][profile-labels] Profile labels before: ${prevLabels.size}, after: ${updatedLabels.size}`)
pendingUpdates.clear()
return updatedLabels
})
@@ -115,10 +123,14 @@ export function useProfileLabels(
*/
const scheduleBatchedUpdate = useCallback(() => {
if (rafScheduledRef.current === null) {
+ console.log(`[shimmer-debug][profile-labels] Scheduling batched update via RAF`)
rafScheduledRef.current = requestAnimationFrame(() => {
+ console.log(`[shimmer-debug][profile-labels] RAF fired, calling applyPendingUpdates`)
applyPendingUpdates()
rafScheduledRef.current = null
})
+ } else {
+ console.log(`[shimmer-debug][profile-labels] RAF already scheduled, skipping`)
}
}, []) // Empty deps: only uses refs which are stable
@@ -265,6 +277,7 @@ export function useProfileLabels(
const label = displayName ? (displayName.startsWith('@') ? displayName : `@${displayName}`) : getNpubFallbackDisplay(pubkey)
// Add to pending updates and schedule batched application
+ console.log(`[shimmer-debug][profile-labels] Adding to pending updates: ${pubkey.slice(0, 16)}...="${label}", pendingUpdates.size=${pendingUpdatesRef.current.size + 1}`)
pendingUpdatesRef.current.set(pubkey, label)
scheduleBatchedUpdate()