forked from mirrors/bookwyrm
Merge pull request #1020 from bookwyrm-social/notification-color
Only make notification count red for mentions
This commit is contained in:
commit
735ef369b9
4 changed files with 22 additions and 3 deletions
|
@ -150,6 +150,19 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
"""for consistent naming"""
|
"""for consistent naming"""
|
||||||
return not self.is_active
|
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", "REPORT"],
|
||||||
|
).exists()
|
||||||
|
|
||||||
activity_serializer = activitypub.Person
|
activity_serializer = activitypub.Person
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -97,10 +97,12 @@ let BookWyrm = new class {
|
||||||
updateCountElement(counter, data) {
|
updateCountElement(counter, data) {
|
||||||
const currentCount = counter.innerText;
|
const currentCount = counter.innerText;
|
||||||
const count = data.count;
|
const count = data.count;
|
||||||
|
const hasMentions = data.has_mentions;
|
||||||
|
|
||||||
if (count != currentCount) {
|
if (count != currentCount) {
|
||||||
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-hidden', count < 1);
|
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-hidden', count < 1);
|
||||||
counter.innerText = count;
|
counter.innerText = count;
|
||||||
|
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-danger', hasMentions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,11 @@
|
||||||
<span class="is-sr-only">{% trans "Notifications" %}</span>
|
<span class="is-sr-only">{% trans "Notifications" %}</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="{% if not request.user|notification_count %}is-hidden {% endif %}tag is-danger is-medium transition-x" data-poll-wrapper>
|
<span
|
||||||
<span data-poll="notifications">{{ request.user | notification_count }}</span>
|
class="{% if not request.user.unread_notification_count %}is-hidden {% elif request.user.has_unread_mentions %}is-danger {% endif %}tag is-medium transition-x"
|
||||||
|
data-poll-wrapper
|
||||||
|
>
|
||||||
|
<span data-poll="notifications">{{ request.user.unread_notification_count }}</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,8 @@ def get_notification_count(request):
|
||||||
"""any notifications waiting?"""
|
"""any notifications waiting?"""
|
||||||
return JsonResponse(
|
return JsonResponse(
|
||||||
{
|
{
|
||||||
"count": request.user.notification_set.filter(read=False).count(),
|
"count": request.user.unread_notification_count,
|
||||||
|
"has_mentions": request.user.has_unread_mentions,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue