Clicking on title marks as read

This commit is contained in:
Greg Shuflin 2025-02-05 01:26:49 -08:00
parent 22a12430e3
commit f95d6a5632
2 changed files with 25 additions and 1 deletions

View File

@ -527,7 +527,6 @@ button:disabled {
.feed-entry-title a {
color: var(--text-color);
text-decoration: none;
flex-grow: 1;
}
.feed-entry-meta {

View File

@ -83,6 +83,31 @@ function renderFeedEntries(entries) {
titleLink.href = entry.link || '#';
titleLink.target = '_blank';
titleLink.textContent = entry.title;
titleLink.onclick = () => {
if (!entry.marked_read) {
// Mark as read in the background, don't wait for it
fetch(`/entries/${entry.id}/state`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
read: true
})
}).then(response => {
if (response.ok) {
entry.marked_read = true;
readToggle.title = 'Mark as unread';
readToggle.innerHTML = '<i class="fa-solid fa-square-check"></i>';
} else {
console.error('Failed to update read state:', response.status);
}
}).catch(error => {
console.error('Failed to update read state:', error);
});
}
// Let the default link behavior happen immediately
};
title.appendChild(titleLink);
const meta = document.createElement('div');