Commit f145286e900a44a9ef3b44754129aaa4175c8550
1 parent
8b79b8d1
Exists in
master
and in
2 other branches
Making category notification update when new messages
Showing
4 changed files
with
25 additions
and
2 deletions
Show diff stats
amadeus/static/js/chat.js
@@ -440,7 +440,7 @@ $('.chat-collapse').on('shown.bs.collapse', function(e) { | @@ -440,7 +440,7 @@ $('.chat-collapse').on('shown.bs.collapse', function(e) { | ||
440 | var url = $(".cat_url").val(); | 440 | var url = $(".cat_url").val(); |
441 | var new_li = $(li).clone(); | 441 | var new_li = $(li).clone(); |
442 | 442 | ||
443 | - new_li.html($(this).parent().find('.panel-title span').text()); | 443 | + new_li.html($(this).parent().find('.panel-title .item_name').text()); |
444 | 444 | ||
445 | $(li).html("<a href='" + url + "'>" + li_text + "</a>"); | 445 | $(li).html("<a href='" + url + "'>" + li_text + "</a>"); |
446 | $(li).append("<span class='divider'>/</span>"); | 446 | $(li).append("<span class='divider'>/</span>"); |
amadeus/static/js/socket.js
@@ -279,6 +279,17 @@ function messageReceived(content) { | @@ -279,6 +279,17 @@ function messageReceived(content) { | ||
279 | span.text(actual); | 279 | span.text(actual); |
280 | } | 280 | } |
281 | }); | 281 | }); |
282 | + | ||
283 | + var item = $("#" + content.space); | ||
284 | + | ||
285 | + if (typeof(item) != "undefined") { | ||
286 | + var span = item.parent().find('span:not(.item_name)'), | ||
287 | + actual = span.text(); | ||
288 | + | ||
289 | + actual = parseInt(actual, 10) + 1; | ||
290 | + | ||
291 | + span.text(actual); | ||
292 | + } | ||
282 | } | 293 | } |
283 | 294 | ||
284 | if (("Notification" in window)) { | 295 | if (("Notification" in window)) { |
chat/templates/chat/list_category.html
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | <div class="col-md-12 category-header"> | 41 | <div class="col-md-12 category-header"> |
42 | <h4 class="panel-title"> | 42 | <h4 class="panel-title"> |
43 | <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | 43 | <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> |
44 | - <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{ category.name }} (<span style="margin-left:0px">{{ category|notifies_category:request.user }}</span>) | 44 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> <span class="item_name">{{ category.name }}</span> (<span style="margin-left:0px">{{ category|notifies_category:request.user }}</span>) |
45 | 45 | ||
46 | </a> | 46 | </a> |
47 | </h4> | 47 | </h4> |
chat/views.py
@@ -277,9 +277,21 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView): | @@ -277,9 +277,21 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView): | ||
277 | if self.object.image: | 277 | if self.object.image: |
278 | simple_notify += " ".join(_("[Photo]")) | 278 | simple_notify += " ".join(_("[Photo]")) |
279 | 279 | ||
280 | + subclass = self.object.talk._my_subclass | ||
281 | + | ||
282 | + if subclass == "generaltalk": | ||
283 | + space_type = "general" | ||
284 | + elif subclass == "categorytalk": | ||
285 | + space_type = "category" | ||
286 | + space = self.object.talk.categorytalk.space.slug | ||
287 | + else: | ||
288 | + space_type = "subject" | ||
289 | + space = self.object.talk.subjecttalk.space.slug | ||
290 | + | ||
280 | notification = { | 291 | notification = { |
281 | "type": "chat", | 292 | "type": "chat", |
282 | "subtype": space_type, | 293 | "subtype": space_type, |
294 | + "space": space, | ||
283 | "user_icon": self.object.user.image_url, | 295 | "user_icon": self.object.user.image_url, |
284 | "notify_title": str(self.object.user), | 296 | "notify_title": str(self.object.user), |
285 | "simple_notify": simple_notify, | 297 | "simple_notify": simple_notify, |