Browse Source

Invalidate the cache upon sending a new PM

Fixes #206.
sh4nks 8 years ago
parent
commit
7e276a47a3
2 changed files with 7 additions and 1 deletions
  1. 1 0
      flaskbb/message/views.py
  2. 6 1
      flaskbb/templates/layout.html

+ 1 - 0
flaskbb/message/views.py

@@ -104,6 +104,7 @@ def view_conversation(conversation_id):
 
         form.save(conversation=conversation, user_id=current_user.id,
                   unread=True)
+        conversation.to_user.invalidate_cache(permissions=False)
 
         return redirect(url_for("message.view_conversation",
                                 conversation_id=old_conv.id))

+ 6 - 1
flaskbb/templates/layout.html

@@ -84,7 +84,12 @@
                             <!-- Inbox -->
                             <li class="dropdown {{ is_active('message.inbox') }}">
                                 <a href="#" class="dropdown-toggle" data-toggle="dropdown">
-                                    <span class="fa fa-envelope"></span> {% trans %}Inbox{% endtrans %} <span class="label label-info">{{ current_user.unread_count }}</span>
+                                    <span class="fa fa-envelope"></span> {% trans %}Inbox{% endtrans %}
+                                    {% if current_user.unread_count > 0 %}
+                                    <span class="label label-danger">{{ current_user.unread_count }}</span>
+                                    {% else %}
+                                    <span class="label label-info">{{ current_user.unread_count }}</span>
+                                    {% endif %}
                                 </a>
                                 <ul class="dropdown-menu dropdown-messages">
                                     {% for message in current_user.unread_messages %}