switch the order of message and chat notifs

master
Aevann 2024-04-18 18:24:19 +02:00
parent 0c92e9e071
commit 78a3b0aeaf
2 changed files with 12 additions and 12 deletions

View File

@ -823,18 +823,13 @@ class User(Base):
@lazy @lazy
def normal_notifications_count(self): def normal_notifications_count(self):
return self.notifications_count \ return self.notifications_count \
- self.chats_notifications_count \
- self.message_notifications_count \ - self.message_notifications_count \
- self.chats_notifications_count \
- self.modmail_notifications_count \ - self.modmail_notifications_count \
- self.post_notifications_count \ - self.post_notifications_count \
- self.modaction_notifications_count \ - self.modaction_notifications_count \
- self.offsite_notifications_count - self.offsite_notifications_count
@property
@lazy
def chats_notifications_count(self):
return g.db.query(ChatMembership).filter_by(user_id=self.id, notification=True).count()
@property @property
@lazy @lazy
def message_notifications_count(self): def message_notifications_count(self):
@ -851,6 +846,11 @@ class User(Base):
return notifs.count() return notifs.count()
@property
@lazy
def chats_notifications_count(self):
return g.db.query(ChatMembership).filter_by(user_id=self.id, notification=True).count()
@property @property
@lazy @lazy
def modmail_notifications_count(self): def modmail_notifications_count(self):
@ -937,10 +937,10 @@ class User(Base):
# only meaningful when notifications_count > 0; otherwise falsely '' ~ normal # only meaningful when notifications_count > 0; otherwise falsely '' ~ normal
if self.normal_notifications_count > 0: if self.normal_notifications_count > 0:
return '' return ''
elif self.chats_notifications_count > 0:
return 'chats'
elif self.message_notifications_count > 0: elif self.message_notifications_count > 0:
return 'messages' return 'messages'
elif self.chats_notifications_count > 0:
return 'chats'
elif self.modmail_notifications_count > 0: elif self.modmail_notifications_count > 0:
return 'modmail' return 'modmail'
elif self.post_notifications_count > 0: elif self.post_notifications_count > 0:

View File

@ -15,13 +15,13 @@
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/chats' %} active{% endif %}" href="/notifications/chats"> <a class="nav-link py-3{% if request.path == '/notifications/messages' %} active{% endif %}" href="/notifications/messages">
Chats {% if v.chats_notifications_count %}<span class="font-weight-bold" style="color:#008080">({{v.chats_notifications_count}})</span>{% endif %} Messages {% if v.message_notifications_count %}<span class="font-weight-bold" style="color:#d8910d">({{v.message_notifications_count}})</span>{% endif %}
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/messages' %} active{% endif %}" href="/notifications/messages"> <a class="nav-link py-3{% if request.path == '/notifications/chats' %} active{% endif %}" href="/notifications/chats">
Messages {% if v.message_notifications_count %}<span class="font-weight-bold" style="color:#d8910d">({{v.message_notifications_count}})</span>{% endif %} Chats {% if v.chats_notifications_count %}<span class="font-weight-bold" style="color:#008080">({{v.chats_notifications_count}})</span>{% endif %}
</a> </a>
</li> </li>
{% if v.admin_level >= PERMS['VIEW_MODMAIL'] %} {% if v.admin_level >= PERMS['VIEW_MODMAIL'] %}