Show each tag's total unread count and remember collapsed sections

Closes gitea#24: the sidebar's per-feed unread counts were already
computed by sidebar() (apps.core.context_processors); each tag group's
total is now the sum of its own feeds' counts (a feed can carry more
than one tag, so this reuses the same per-feed data rather than a
second query) and renders next to the tag name like a feed's own
count.

Closes gitea#25: each sidebar <details> section (one per tag, plus
"Untagged") now carries a stable data-sidebar-key, and
static/js/sidebar-state.js remembers which ones are collapsed in
localStorage — this isn't a SPA, so every click re-renders the sidebar
server-side, and previously every section reset back to expanded on
the next page load. Per-browser, same pattern as theme.js/theme-init.js,
not synced across devices/accounts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-31 12:34:57 -06:00
1 parent 9439f9cc59
commit e760eeda1d
7 files changed
+186 -6

No files matched your search

+7 -4
View File
@@ -31,10 +31,13 @@
</ul>
{% for entry in sidebar_tag_groups %}
<details class="sidebar-section" open>
<details class="sidebar-section" data-sidebar-key="tag-{{ entry.tag.pk }}" open>
<summary>
<a href="{% url 'reader:stream' %}?tag={{ entry.tag.pk }}"
class="sidebar-tag-link{% if request.GET.tag == entry.tag.pk|stringformat:'s' %} active{% endif %}">{{ entry.tag.name }}</a>
<span class="sidebar-tag-row">
<a href="{% url 'reader:stream' %}?tag={{ entry.tag.pk }}"
class="sidebar-tag-link{% if request.GET.tag == entry.tag.pk|stringformat:'s' %} active{% endif %}">{{ entry.tag.name }}</a>
{% if entry.unread_count %}<span class="unread-count">{{ entry.unread_count }}</span>{% endif %}
</span>
</summary>
{% if entry.subscriptions %}
<ul class="sidebar-item-list">
@@ -54,7 +57,7 @@
{% endfor %}
{% if sidebar_untagged %}
<details class="sidebar-section" open>
<details class="sidebar-section" data-sidebar-key="untagged" open>
<summary>Untagged</summary>
<ul class="sidebar-item-list">
{% for subscription in sidebar_untagged %}