debug: add comprehensive logging for profile loading states and article refresh

- Add logs to useProfileLabels for loading state tracking
- Add logs to markdown processing to track when content is cleared/reprocessed
- Add logs to article loader for refresh behavior
- Add logs to ResolvedMention and NostrMentionLink for loading detection
- Add logs to nostr URI resolver when loading state is shown
- All logs prefixed with meaningful tags for easy filtering
This commit is contained in:
Gigi
2025-11-02 22:39:07 +01:00
parent 7e5972a6e2
commit 51a4b545e9
6 changed files with 45 additions and 6 deletions

View File

@@ -45,15 +45,25 @@ const NostrMentionLink: React.FC<NostrMentionLinkProps> = ({
if (!pubkey) return false
// Check cache
const cached = loadCachedProfiles([pubkey])
if (cached.has(pubkey)) return true
if (cached.has(pubkey)) {
console.log(`[nostr-mention-link] ${nostrUri.slice(0, 30)}... in cache`)
return true
}
// Check eventStore
const eventStoreProfile = eventStore?.getEvent(pubkey + ':0')
return !!eventStoreProfile
}, [pubkey, eventStore])
const inStore = !!eventStoreProfile
if (inStore) {
console.log(`[nostr-mention-link] ${nostrUri.slice(0, 30)}... in eventStore`)
}
return inStore
}, [pubkey, eventStore, nostrUri])
// Show loading if profile doesn't exist and not in cache/store (for npub/nprofile)
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})`)
}
// If decoding failed, show shortened identifier
if (!decoded) {

View File

@@ -30,14 +30,24 @@ const ResolvedMention: React.FC<ResolvedMentionProps> = ({ encoded }) => {
if (!pubkey) return false
// Check cache
const cached = loadCachedProfiles([pubkey])
if (cached.has(pubkey)) return true
if (cached.has(pubkey)) {
console.log(`[resolved-mention] ${encoded?.slice(0, 16)}... in cache`)
return true
}
// Check eventStore
const eventStoreProfile = eventStore?.getEvent(pubkey + ':0')
return !!eventStoreProfile
}, [pubkey, eventStore])
const inStore = !!eventStoreProfile
if (inStore) {
console.log(`[resolved-mention] ${encoded?.slice(0, 16)}... in eventStore`)
}
return inStore
}, [pubkey, eventStore, 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})`)
}
const display = pubkey ? getProfileDisplayName(profile, pubkey) : encoded
const npub = pubkey ? npubEncode(pubkey) : undefined