debug: add log to verify post-processing adds loading class

- Log when loading class is added to profile links during post-processing
- Will help verify the shimmer is being applied correctly
This commit is contained in:
Gigi
2025-11-02 22:59:28 +01:00
parent 1eca19154d
commit 0bf33f1a7d
2 changed files with 9 additions and 10 deletions

View File

@@ -241,13 +241,8 @@ export function useProfileLabels(
}
})
// Set fallback labels for profiles that weren't found
profileData.forEach(({ pubkey }) => {
if (!labels.has(pubkey)) {
const fallback = getNpubFallbackDisplay(pubkey)
labels.set(pubkey, fallback)
}
})
// Don't set fallback labels in the Map - we'll use fallback directly when rendering
// This allows us to distinguish between "no label yet" (use fallback) vs "resolved label" (use Map value)
setProfileLabels(new Map(labels))
setProfileLoading(new Map(loading))

View File

@@ -339,12 +339,14 @@ export function replaceNostrUrisInMarkdownWithProfileLabels(
const pubkey = decoded.type === 'npub' ? decoded.data : decoded.data.pubkey
// Check if we have a resolved profile name using pubkey as key
if (profileLabels.has(pubkey)) {
// Only use Map value if profile is not loading (meaning it's actually resolved)
const isLoading = profileLoading.get(pubkey)
if (!isLoading && profileLabels.has(pubkey)) {
const displayName = profileLabels.get(pubkey)!
return `[${displayName}](${link})`
}
// If no resolved label yet, use fallback (will show loading via post-processing)
// If loading or no resolved label yet, use fallback (will show loading via post-processing)
const label = getNostrUriLabel(encoded)
return `[${label}](${link})`
}
@@ -381,7 +383,9 @@ export function addLoadingClassToProfileLinks(
const pubkey = decoded.data
// Check if this profile is loading
if (profileLoading.get(pubkey) === true) {
const isLoading = profileLoading.get(pubkey)
if (isLoading === true) {
console.log(`[profile-loading-debug][post-process] Adding loading class to link for ${pubkey.slice(0, 16)}...`)
// Add profile-loading class if not already present
if (!match.includes('profile-loading')) {
// Insert class before the closing >