Commit 72992dfcae1caad4b42c7ffc64f66f7a5b2aa51c

Authored by Zambom
1 parent 1ba9511f

Updating last message chat date when new arrives

Showing 2 changed files with 7 additions and 2 deletions   Show diff stats
amadeus/static/js/socket.js
... ... @@ -242,11 +242,14 @@ function messageReceived(content) {
242 242 } else {
243 243 var talk_line = $("#talk-" + content.container),
244 244 talk_notifies = talk_line.find('.chat_notify'),
245   - actual_count = talk_notifies.text();
  245 + actual_count = talk_notifies.text(),
  246 + actual_date = talk_line.find(".talk-last_msg");
246 247  
247 248 actual_count = parseInt(actual_count, 10) + 1;
248 249  
249 250 talk_notifies.text(actual_count);
  251 +
  252 + actual_date.html(content.last_date);
250 253  
251 254 $('.chat_badge').each(function () {
252 255 var actual = $(this).text();
... ...
chat/views.py
... ... @@ -7,6 +7,7 @@ from django.http import JsonResponse
7 7 from django.template.loader import render_to_string
8 8 from django.core.urlresolvers import reverse, reverse_lazy
9 9 import textwrap
  10 +from django.utils import formats
10 11 from django.utils.html import strip_tags
11 12 from django.utils.translation import ugettext_lazy as _
12 13 from django.contrib.auth.mixins import LoginRequiredMixin
... ... @@ -193,7 +194,8 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView):
193 194 "notify_title": str(self.object.user),
194 195 "simple_notify": simple_notify,
195 196 "complete": render_to_string("chat/_message.html", {"talk_msg": self.object}, self.request),
196   - "container": "chat-" + str(self.object.user.id)
  197 + "container": "chat-" + str(self.object.user.id),
  198 + "last_date": _("Last message in %s")%(formats.date_format(self.object.create_date, "SHORT_DATETIME_FORMAT"))
197 199 }
198 200  
199 201 notification = json.dumps(notification)
... ...