diff --git a/app/views/conversations/_conversation.haml b/app/views/conversations/_conversation.haml index 2083a53b70c581873634943945e94265c1a0ca48..0b7b84a75b0a806b1618d34ce1587583a82a8275 100644 --- a/app/views/conversations/_conversation.haml +++ b/app/views/conversations/_conversation.haml @@ -2,7 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -%a.conversation{:href => conversations_path(:conversation_id => conversation.id)} +%a.conversation{:href => conversation_path(conversation)} .stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('unread' if unread_counts[conversation.id].to_i > 0)} = person_image_tag(conversation.author) diff --git a/app/views/conversations/show.haml b/app/views/conversations/show.haml index b5d871dfcc185200c13ecada985bba11edaacad9..9aa7f520ea91e36e9a9223778f52d0d6f15b0b44 100644 --- a/app/views/conversations/show.haml +++ b/app/views/conversations/show.haml @@ -2,4 +2,5 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. + = render 'show', :conversation => @conversation diff --git a/app/views/conversations/index.js.erb b/app/views/conversations/show.js.erb similarity index 100% rename from app/views/conversations/index.js.erb rename to app/views/conversations/show.js.erb diff --git a/public/javascripts/inbox.js b/public/javascripts/inbox.js index 00435e90dd40fea16c952478999984b5f028578f..013bcc1362a1cb663ca67a423ce630d36599eaa8 100644 --- a/public/javascripts/inbox.js +++ b/public/javascripts/inbox.js @@ -8,12 +8,30 @@ $(document).ready(function(){ $('a.conversation').live('click', function(){ $.getScript(this.href); history.pushState(null, "", this.href); + + var conv = $(this).children('.stream_element'), + cBadge = $("#message_inbox_badge").children(".badge_count"); + if(conv.hasClass('unread') ){ + conv.removeClass('unread'); + } + if(cBadge.html() != null) { + cBadge.html().replace(/\d+/, function(num){ + num = parseInt(num); + cBadge.html(parseInt(num)-1); + if(num == 1) { + cBadge.addClass("hidden"); + } + }); + } + return false; }); $(window).bind("popstate", function(){ - $.getScript(location.href); - return false; + if (location.href.match(/conversations\/\d+/) != null) { + $.getScript(location.href); + return false; + } }); resize();