Private
Public Access
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:
1 parent
9439f9cc59
commit
e760eeda1d
7 files changed
+186
-6
No files matched your search
@@ -164,3 +164,27 @@ def test_saved_filter_only_shows_saved_articles(client, alice, alices_article):
|
||||
|
||||
response = client.get(reverse("reader:stream"), {"filter": "starred"})
|
||||
assert alices_article.title not in response.content.decode()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sidebar_shows_a_tags_total_unread_count(client, alice):
|
||||
from apps.articles.models import SubscriptionTag, Tag
|
||||
|
||||
feed_a = Feed.objects.create(feed_url="https://a.example.com/feed.xml")
|
||||
feed_b = Feed.objects.create(feed_url="https://b.example.com/feed.xml")
|
||||
sub_a = Subscription.objects.create(user=alice, feed=feed_a)
|
||||
sub_b = Subscription.objects.create(user=alice, feed=feed_b)
|
||||
tag = Tag.objects.create(user=alice, name="work")
|
||||
SubscriptionTag.objects.create(user=alice, subscription=sub_a, tag=tag)
|
||||
SubscriptionTag.objects.create(user=alice, subscription=sub_b, tag=tag)
|
||||
for i in range(3):
|
||||
Article.objects.create(feed=feed_a, guid=f"a-{i}", title=f"A{i}")
|
||||
for i in range(4):
|
||||
Article.objects.create(feed=feed_b, guid=f"b-{i}", title=f"B{i}")
|
||||
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
response = client.get(reverse("reader:stream"))
|
||||
|
||||
# The only "7" on the page — the individual feeds show 3 and 4.
|
||||
content = response.content.decode()
|
||||
assert '<span class="unread-count">7</span>' in content
|
||||
Reference in new issue
Block a user