Private
Public Access
Make the banner and sidebar counts live on every page
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>
This commit is contained in:
1 parent
fed5bcc49e
commit
2a3e9f632e
18 files changed
+399
-196
No files matched your search
+4
-2
@@ -38,7 +38,9 @@
|
||||
{% endif %}
|
||||
|
||||
<main class="{% if user.is_authenticated %}app-content{% else %}auth-content{% endif %}">
|
||||
{% if not user.is_authenticated %}
|
||||
{% if user.is_authenticated %}
|
||||
<button type="button" class="new-articles-banner" data-stream-url="{% url 'reader:stream' %}" hidden></button>
|
||||
{% else %}
|
||||
<div class="auth-brand">
|
||||
<img src="{% static 'img/brand-full-dark.png' %}" alt="Evection" class="brand-wordmark-dark">
|
||||
<img src="{% static 'img/brand-full-light.png' %}" alt="Evection" class="brand-wordmark-light">
|
||||
@@ -58,7 +60,7 @@
|
||||
{% if user.is_authenticated %}
|
||||
<script src="{% static 'js/theme.js' %}" defer></script>
|
||||
<script src="{% static 'js/sidebar-state.js' %}" defer></script>
|
||||
<script src="{% static 'js/tab-badge.js' %}" data-url="{% url 'reader:new_since' %}" defer></script>
|
||||
<script src="{% static 'js/live-updates.js' %}" data-url="{% url 'reader:new_since' %}" data-since="{{ latest_article_id }}" defer></script>
|
||||
{% endif %}
|
||||
<script src="{% static 'js/register-sw.js' %}" defer></script>
|
||||
</body>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<li>
|
||||
<a href="{% url 'reader:stream' %}?filter=starred"
|
||||
class="{% if request.GET.filter == 'starred' %}active{% endif %}">
|
||||
Favourites{% if sidebar_starred_count %} ({{ sidebar_starred_count }}){% endif %}
|
||||
Favourites <span class="starred-count" data-starred-count{% if not sidebar_starred_count %} hidden{% endif %}>({{ sidebar_starred_count }})</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -36,7 +36,7 @@
|
||||
<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 class="unread-count" data-tag-id="{{ entry.tag.pk }}"{% if not entry.unread_count %} hidden{% endif %}>{% if entry.unread_count %}{{ entry.unread_count }}{% endif %}</span>
|
||||
</span>
|
||||
</summary>
|
||||
{% if entry.subscriptions %}
|
||||
@@ -48,7 +48,7 @@
|
||||
{% if subscription.feed.favicon_url %}<img src="{{ subscription.feed.favicon_url }}" alt="" class="feed-favicon">{% endif %}
|
||||
<span>{{ subscription.display_title }}</span>
|
||||
</a>
|
||||
{% if subscription.unread_count %}<span class="unread-count">{{ subscription.unread_count }}</span>{% endif %}
|
||||
<span class="unread-count" data-feed-id="{{ subscription.feed_id }}"{% if not subscription.unread_count %} hidden{% endif %}>{% if subscription.unread_count %}{{ subscription.unread_count }}{% endif %}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -67,7 +67,7 @@
|
||||
{% if subscription.feed.favicon_url %}<img src="{{ subscription.feed.favicon_url }}" alt="" class="feed-favicon">{% endif %}
|
||||
<span>{{ subscription.display_title }}</span>
|
||||
</a>
|
||||
{% if subscription.unread_count %}<span class="unread-count">{{ subscription.unread_count }}</span>{% endif %}
|
||||
<span class="unread-count" data-feed-id="{{ subscription.feed_id }}"{% if not subscription.unread_count %} hidden{% endif %}>{% if subscription.unread_count %}{{ subscription.unread_count }}{% endif %}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{% if new_count %}
|
||||
<button type="button" class="new-articles-banner">
|
||||
{{ new_count }} new article{{ new_count|pluralize }} — click to show
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -23,11 +23,5 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="new-articles-banner"
|
||||
hx-get="{% url 'reader:check_new' %}?since={{ latest_article_id }}&{{ new_check_qs }}"
|
||||
hx-trigger="every 30s"
|
||||
hx-target="this"
|
||||
hx-swap="innerHTML"></div>
|
||||
|
||||
{% include "reader/_article_list.html" %}
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user