diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py
index 3efbd6ac8..257264681 100644
--- a/bookwyrm/models/user.py
+++ b/bookwyrm/models/user.py
@@ -150,6 +150,19 @@ class User(OrderedCollectionPageMixin, AbstractUser):
"""for consistent naming"""
return not self.is_active
+ @property
+ def unread_notification_count(self):
+ """ count of notifications, for the templates """
+ return self.notification_set.filter(read=False).count()
+
+ @property
+ def has_unread_mentions(self):
+ """ whether any of the unread notifications are conversations """
+ return self.notification_set.filter(
+ read=False,
+ notification_type__in=["REPLY", "MENTION", "TAG"],
+ ).exists()
+
activity_serializer = activitypub.Person
@classmethod
diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js
index 485daf15b..3659a20e4 100644
--- a/bookwyrm/static/js/bookwyrm.js
+++ b/bookwyrm/static/js/bookwyrm.js
@@ -97,10 +97,12 @@ let BookWyrm = new class {
updateCountElement(counter, data) {
const currentCount = counter.innerText;
const count = data.count;
+ const hasMentions = data.has_mentions;
if (count != currentCount) {
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-hidden', count < 1);
counter.innerText = count;
+ this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-danger', hasMentions);
}
}
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html
index 84482cdfc..770666e80 100644
--- a/bookwyrm/templates/layout.html
+++ b/bookwyrm/templates/layout.html
@@ -135,8 +135,11 @@
{% trans "Notifications" %}
-
- {{ request.user | notification_count }}
+
+ {{ request.user.unread_notification_count }}
diff --git a/bookwyrm/views/updates.py b/bookwyrm/views/updates.py
index 349022724..726145626 100644
--- a/bookwyrm/views/updates.py
+++ b/bookwyrm/views/updates.py
@@ -10,7 +10,8 @@ def get_notification_count(request):
"""any notifications waiting?"""
return JsonResponse(
{
- "count": request.user.notification_set.filter(read=False).count(),
+ "count": request.user.unread_notification_count,
+ "has_mentions": request.user.has_unread_mentions,
}
)