optimize main page notifications

This commit is contained in:
imperosol
2025-09-29 08:45:42 +02:00
parent 03f53e921b
commit 8ff25e6034

View File

@@ -77,22 +77,22 @@
<div class="notification" x-data="{display: false}" :class="{white: display}"> <div class="notification" x-data="{display: false}" :class="{white: display}">
<a href="#" @click.prevent="display = !display"> <a href="#" @click.prevent="display = !display">
<i :class="`fa-${display ? 'solid': 'regular'} fa-bell`" x-transition></i> <i :class="`fa-${display ? 'solid': 'regular'} fa-bell`" x-transition></i>
{% set notification_count = user.notifications.filter(viewed=False).count() %} {% set notifications = user.notifications.filter(viewed=False).order_by("-date")|list %}
{% if notification_count > 0 %} {%- if notifications|length > 0 -%}
<span> <span>
{% if notification_count < 100 %} {% if notifications|length < 100 %}
{{ notification_count }} {{ notifications|length }}
{% else %} {%- else -%}
&nbsp; 99+
{% endif %} {%- endif -%}
</span> </span>
{% endif %} {% endif %}
</a> </a>
<div id="header_notif" x-show="display" x-cloak x-transition @click.outside="display = false"> <div id="header_notif" x-show="display" x-cloak x-transition @click.outside="display = false">
<ul> <ul>
{% if user.notifications.filter(viewed=False).count() > 0 %} {%- if notifications|length > 0 -%}
{% for n in user.notifications.filter(viewed=False).order_by('-date') %} {%- for n in notifications -%}
<li> <li>
<a href="{{ url("core:notification", notif_id=n.id) }}"> <a href="{{ url("core:notification", notif_id=n.id) }}">
<div class="datetime"> <div class="datetime">
@@ -108,10 +108,10 @@
</div> </div>
</a> </a>
</li> </li>
{% endfor %} {%- endfor -%}
{% else %} {%- else -%}
<li class="empty-notification">{% trans %}You do not have any unread notification{% endtrans %}</li> <li class="empty-notification">{% trans %}You do not have any unread notification{% endtrans %}</li>
{% endif %} {%- endif -%}
</ul> </ul>
<div class="options"> <div class="options">
<a href="{{ url('core:notification_list') }}"> <a href="{{ url('core:notification_list') }}">