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>
15 lines
578 B
Python
15 lines
578 B
Python
from django.db.models.signals import post_delete, post_save
|
|
from django.dispatch import receiver
|
|
|
|
from apps.core.cache_utils import invalidate_sidebar_unread_cache
|
|
|
|
from .models import Subscription
|
|
|
|
|
|
@receiver([post_save, post_delete], sender=Subscription)
|
|
def drop_sidebar_counts_when_subscriptions_change(sender, instance, **kwargs):
|
|
"""The cached per-feed unread counts only cover feeds the user was
|
|
subscribed to when they were computed, so a new subscription would
|
|
show no count until the cache expired."""
|
|
invalidate_sidebar_unread_cache(instance.user_id)
|