mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 14:44:26 +01:00
fix: simplify cache save logic to avoid TypeScript errors
Simplify the finalization cache save - we already save on first event, so only save in finalization if first event wasn't emitted. This avoids TypeScript narrowing issues and duplicate cache saves.
This commit is contained in:
@@ -401,12 +401,10 @@ export function useArticleLoader({
|
|||||||
|
|
||||||
// Save to cache for future loads (if we haven't already saved from first event)
|
// Save to cache for future loads (if we haven't already saved from first event)
|
||||||
// Only save if this is a different/newer event than what we first rendered
|
// Only save if this is a different/newer event than what we first rendered
|
||||||
if (!firstEmitted || (latestEvent && finalEvent.id !== latestEvent.id)) {
|
// Note: We already saved from first event, so only save if this is different
|
||||||
console.log('[article-loader] Saving newer event to cache', {
|
if (!firstEmitted) {
|
||||||
wasFirstEmitted: firstEmitted,
|
// First event wasn't emitted, so save now
|
||||||
finalEventId: finalEvent.id,
|
console.log('[article-loader] Saving event to cache (first event was not emitted)')
|
||||||
latestEventId: latestEvent?.id
|
|
||||||
})
|
|
||||||
const articleContent = {
|
const articleContent = {
|
||||||
title,
|
title,
|
||||||
markdown: finalEvent.content,
|
markdown: finalEvent.content,
|
||||||
@@ -418,7 +416,8 @@ export function useArticleLoader({
|
|||||||
}
|
}
|
||||||
saveToCache(naddr, articleContent)
|
saveToCache(naddr, articleContent)
|
||||||
} else {
|
} else {
|
||||||
console.log('[article-loader] Cache already saved from first event, skipping')
|
// Cache was already saved when first event was received
|
||||||
|
console.log('[article-loader] Cache already saved from first event, skipping duplicate save')
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[article-loader] ✅ Finalized with event from relays')
|
console.log('[article-loader] ✅ Finalized with event from relays')
|
||||||
|
|||||||
Reference in New Issue
Block a user