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 | 440 | var url = $(".cat_url").val(); |
441 | 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 | 445 | $(li).html("<a href='" + url + "'>" + li_text + "</a>"); |
446 | 446 | $(li).append("<span class='divider'>/</span>"); | ... | ... |
amadeus/static/js/socket.js
... | ... | @@ -279,6 +279,17 @@ function messageReceived(content) { |
279 | 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 | 295 | if (("Notification" in window)) { | ... | ... |
chat/templates/chat/list_category.html
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | <div class="col-md-12 category-header"> |
42 | 42 | <h4 class="panel-title"> |
43 | 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 | 46 | </a> |
47 | 47 | </h4> | ... | ... |
chat/views.py
... | ... | @@ -277,9 +277,21 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView): |
277 | 277 | if self.object.image: |
278 | 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 | 291 | notification = { |
281 | 292 | "type": "chat", |
282 | 293 | "subtype": space_type, |
294 | + "space": space, | |
283 | 295 | "user_icon": self.object.user.image_url, |
284 | 296 | "notify_title": str(self.object.user), |
285 | 297 | "simple_notify": simple_notify, | ... | ... |