Update notification bell when notifications have been cleared

This commit is contained in:
Jeremy Stretch 2024-07-11 11:52:55 -04:00
parent 5131cc92f0
commit 4f0cc950bc
3 changed files with 12 additions and 5 deletions

View File

@ -29,3 +29,5 @@
</a> </a>
{% endif %} {% endif %}
</div> </div>
{% include 'inc/notification_bell.html' %}

View File

@ -0,0 +1,9 @@
{% if notifications %}
<span class="text-primary" id="notifications-alert" hx-swap-oob="true">
<i class="mdi mdi-bell-badge"></i>
</span>
{% else %}
<span class="text-muted" id="notifications-alert" hx-swap-oob="true">
<i class="mdi mdi-bell"></i>
</span>
{% endif %}

View File

@ -6,11 +6,7 @@
{% with notifications=request.user.notifications.unread.exists %} {% with notifications=request.user.notifications.unread.exists %}
<div class="nav-item dropdown"> <div class="nav-item dropdown">
<a href="#" class="nav-link" data-bs-toggle="dropdown" hx-get="{% url 'extras:notifications' %}" hx-target="next .notifications" aria-label="Notifications"> <a href="#" class="nav-link" data-bs-toggle="dropdown" hx-get="{% url 'extras:notifications' %}" hx-target="next .notifications" aria-label="Notifications">
{% if notifications %} {% include 'inc/notification_bell.html' %}
<span class="text-primary"><i class="mdi mdi-bell-badge"></i></span>
{% else %}
<i class="mdi mdi-bell"></i>
{% endif %}
</a> </a>
<div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow notifications"></div> <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow notifications"></div>
</div> </div>