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

@@ -207,6 +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`)
return
}
@@ -226,12 +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`)
} 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`)
}
})
@@ -245,9 +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}`))
// 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) + '...'))
const pubkeysToFetchSet = new Set(pubkeysToFetch)
// Create a map from pubkey to encoded identifier for quick lookup
const pubkeyToEncoded = new Map<string, string>()
@@ -274,6 +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`)
setProfileLoading(prevLoading => {
const updated = new Map(prevLoading)
updated.set(encoded, false)
@@ -288,12 +294,17 @@ 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`)
setProfileLoading(prevLoading => {
const updated = new Map(prevLoading)
pubkeysToFetch.forEach(pubkey => {
const encoded = pubkeyToEncoded.get(pubkey)
if (encoded) {
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`)
}
}
})
return updated