Private
Public Access
One 5-minute poll (/new-since/) now drives the new-articles banner, the tab dot and the sidebar counts, across all subscriptions rather than the selected feed/tag. The banner lives in the base layout with a server-rendered baseline id and reloads the current view on click; new articles are never inserted automatically. Sidebar counts are patched in place by the poll, and immediately after reading or starring (HX-Trigger: countsChanged). Ingestion, filter rules and subscription changes now drop the cached counts instead of waiting out the TTL. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
// Delegated listeners, not inline onclick="" attributes: production's
|
|
// Content Security Policy (config/settings/prod.py, script-src 'self')
|
|
// blocks inline event handlers, which silently turned the title click into
|
|
// a plain link to the detail page and the new-articles banner into a no-op.
|
|
|
|
function toggleArticle(link) {
|
|
var row = link.closest("li.article-row");
|
|
var body = row.querySelector(".article-inline-body");
|
|
var wasOpen = row.classList.contains("is-expanded");
|
|
|
|
document.querySelectorAll("li.article-row.is-expanded").forEach(function (openRow) {
|
|
openRow.classList.remove("is-expanded");
|
|
var openBody = openRow.querySelector(".article-inline-body");
|
|
if (openBody) {
|
|
openBody.hidden = true;
|
|
}
|
|
});
|
|
|
|
if (!wasOpen) {
|
|
row.classList.add("is-expanded");
|
|
body.hidden = false;
|
|
if (!body.dataset.loaded) {
|
|
body.dataset.loaded = "1";
|
|
htmx.ajax("GET", link.dataset.inlineUrl, { target: body, swap: "innerHTML" }).then(
|
|
function () {
|
|
row.classList.add("is-read");
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
document.addEventListener("click", function (event) {
|
|
var link = event.target.closest("a.article-title[data-inline-url]");
|
|
if (link) {
|
|
// Leave modified clicks alone so "open in new tab" still works.
|
|
if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
|
|
return;
|
|
}
|
|
event.preventDefault();
|
|
toggleArticle(link);
|
|
return;
|
|
}
|
|
var banner = event.target.closest(".new-articles-banner");
|
|
if (banner) {
|
|
// Reloading keeps the current filter/tag/feed in the URL; from any
|
|
// other page (settings, search) go to the stream instead.
|
|
if (location.pathname === banner.dataset.streamUrl) {
|
|
location.reload();
|
|
} else {
|
|
location.href = banner.dataset.streamUrl;
|
|
}
|
|
}
|
|
});
|