feat(profile): preload all highlights and writings into event store

This commit is contained in:
Gigi
2025-10-19 01:15:01 +02:00
parent 016e369fb1
commit a862eb880e

View File

@@ -411,6 +411,34 @@ const Me: React.FC<MeProps> = ({
}
}, [isOwnProfile, myWritings])
// Preload all highlights and writings for profile pages (non-blocking)
useEffect(() => {
if (!isOwnProfile && viewingPubkey && relayPool && eventStore) {
// Fire and forget - non-blocking background fetch
console.log('🔄 [Profile] Preloading highlights and writings for', viewingPubkey.slice(0, 8))
// Fetch highlights in background
fetchHighlights(relayPool, viewingPubkey, undefined, undefined, false, eventStore)
.then(highlights => {
console.log('✅ [Profile] Preloaded', highlights.length, 'highlights into event store')
})
.catch(err => {
console.warn('⚠️ [Profile] Failed to preload highlights:', err)
})
// Fetch writings in background
fetchBlogPostsFromAuthors(relayPool, [viewingPubkey], RELAYS)
.then(writings => {
// Store writings in event store
writings.forEach(w => eventStore.add(w.event))
console.log('✅ [Profile] Preloaded', writings.length, 'writings into event store')
})
.catch(err => {
console.warn('⚠️ [Profile] Failed to preload writings:', err)
})
}
}, [isOwnProfile, viewingPubkey, relayPool, eventStore])
// Pull-to-refresh - reload active tab without clearing state
const { isRefreshing, pullPosition } = usePullToRefresh({
onRefresh: () => {