fix(content): render markdown immediately while computing highlights; prevent initial login refresh from overwriting article highlights

This commit is contained in:
Gigi
2025-10-05 21:45:47 +01:00
parent 9638ab0b84
commit d148433fcc
2 changed files with 14 additions and 5 deletions

View File

@@ -77,7 +77,11 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
useEffect(() => {
if (!relayPool || !activeAccount) return
handleFetchBookmarks()
handleFetchHighlights()
// Avoid overwriting article-specific highlights during initial article load
// If an article is being viewed (naddr present), let useArticleLoader own the first highlights set
if (!naddr) {
handleFetchHighlights()
}
handleFetchContacts()
}, [relayPool, activeAccount?.pubkey])

View File

@@ -76,7 +76,6 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
// Check if we need to wait for HTML conversion
const needsHtmlConversion = markdown && !renderedHtml
const shouldShowContent = !needsHtmlConversion || relevantHighlights.length === 0
// Attach click handlers to highlight marks
useEffect(() => {
@@ -188,11 +187,11 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
</div>
)}
{markdown || html ? (
finalHtml || (markdown && shouldShowContent) ? (
markdown ? (
finalHtml ? (
<div
ref={contentRef}
className={markdown ? "reader-markdown" : "reader-html"}
className="reader-markdown"
dangerouslySetInnerHTML={{ __html: finalHtml }}
/>
) : (
@@ -205,7 +204,13 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
</ReactMarkdown>
</div>
)
) : null
) : (
<div
ref={contentRef}
className="reader-html"
dangerouslySetInnerHTML={{ __html: finalHtml || html }}
/>
)
) : (
<div className="reader empty">
<p>No readable content found for this URL.</p>