diff --git a/client/js/templates/Item.jsx b/client/js/templates/Item.jsx index e268fc5ff4..c52175781c 100644 --- a/client/js/templates/Item.jsx +++ b/client/js/templates/Item.jsx @@ -46,10 +46,6 @@ function setupLightbox({ })); } -function stopPropagation(event) { - event.stopPropagation(); -} - function lazyLoadImages(content) { content.querySelectorAll('img').forEach((img) => { img.setAttribute('src', img.getAttribute('data-selfoss-src')); @@ -257,6 +253,8 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa [currentTime, item.datetime] ); + const canWrite = useAllowedToWrite(); + const previouslyExpanded = usePreviousImmediate(expanded); const configuration = useContext(ConfigurationContext); @@ -369,6 +367,15 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa [history, location, expanded, item.id] ); + const titleOnAuxClick = useCallback( + (event) => { + if (event.button === 1 && canWrite) { + selfoss.entriesPage.markEntryRead(item.id, true); + } + }, + [canWrite, item.id] + ); + const starOnClick = useCallback( (event) => { event.preventDefault(); @@ -387,6 +394,17 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa [item] ); + const externalLinkOnClick = useCallback( + (event) => { + event.stopPropagation(); + + if (canWrite) { + selfoss.entriesPage.markEntryRead(item.id, true); + } + }, + [canWrite, item.id] + ); + const loadImagesOnClick = useCallback( (event) => loadImages({ event, setImagesLoaded, contentBlock }), [] @@ -411,8 +429,6 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa [item.source] ); - const canWrite = useAllowedToWrite(); - const _ = useContext(LocalizationContext); const sharers = useSharers({ configuration, _ }); @@ -446,12 +462,13 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa className="entry-title" onClick={titleOnClick} > - @@ -544,7 +561,7 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa target="_blank" rel="noreferrer" accessKey="o" - onClick={stopPropagation} + onClick={externalLinkOnClick} > {_('open_window')} @@ -599,7 +616,7 @@ export default function Item({ currentTime, item, selected, expanded, setNavExpa target="_blank" rel="noreferrer" accessKey="o" - onClick={stopPropagation} + onClick={externalLinkOnClick} > {_('open_window')} diff --git a/client/styles/main.scss b/client/styles/main.scss index efd84b1f52..6583afab20 100644 --- a/client/styles/main.scss +++ b/client/styles/main.scss @@ -526,7 +526,8 @@ span.offline-count.diff { } .entry-title a { - color: var(--primary); + color: inherit; + text-decoration: none; } .entry.unread .entry-title {