mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +01:00
feat: implement smart highlight clearing for articles
- Preserve highlights that belong to the current article when switching articles - Only clear highlights that don't match the current article coordinate or event ID - Improve user experience by maintaining relevant highlights during navigation
This commit is contained in:
@@ -76,8 +76,8 @@ export function useArticleLoader({
|
|||||||
setSelectedUrl(`nostr:${naddr}`)
|
setSelectedUrl(`nostr:${naddr}`)
|
||||||
setIsCollapsed(true)
|
setIsCollapsed(true)
|
||||||
|
|
||||||
// Clear highlights immediately when starting to load a new article
|
// Don't clear highlights yet - let the smart filtering logic handle it
|
||||||
setHighlights([])
|
// when we know the article coordinate
|
||||||
setHighlightsLoading(false) // Don't show loading yet
|
setHighlightsLoading(false) // Don't show loading yet
|
||||||
|
|
||||||
// If we have preview data from navigation, show it immediately (no skeleton!)
|
// If we have preview data from navigation, show it immediately (no skeleton!)
|
||||||
@@ -241,7 +241,13 @@ export function useArticleLoader({
|
|||||||
|
|
||||||
if (coord && eventId) {
|
if (coord && eventId) {
|
||||||
setHighlightsLoading(true)
|
setHighlightsLoading(true)
|
||||||
setHighlights([])
|
// Clear highlights that don't belong to this article coordinate
|
||||||
|
setHighlights((prev) => {
|
||||||
|
return prev.filter(h => {
|
||||||
|
// Keep highlights that match this article coordinate or event ID
|
||||||
|
return h.eventReference === coord || h.eventReference === eventId
|
||||||
|
})
|
||||||
|
})
|
||||||
await fetchHighlightsForArticle(
|
await fetchHighlightsForArticle(
|
||||||
relayPool,
|
relayPool,
|
||||||
coord,
|
coord,
|
||||||
|
|||||||
Reference in New Issue
Block a user