Allow subject counts to increase from zero.

Before this fix, you could expand a stream, and then any
subjects that already had a zero count could not be
incremented when new messages came in, until you rebuilt
the subject list again.

(imported from commit 98c95e201f6ec745d7c857da6f42495c8bf88ee0)
This commit is contained in:
Steve Howell 2013-06-06 20:46:01 -04:00
parent cc8a04cb71
commit 0087ad1131
3 changed files with 10 additions and 4 deletions

View File

@ -131,6 +131,7 @@ exports.set_subject_count = function (stream, subject, count) {
return;
}
count_span.removeClass("zero_count");
update_count_in_dom(count_span, value_span, count);
};
@ -150,7 +151,7 @@ function rebuild_recent_subjects(stream, subject) {
$.each(subjects, function (idx, subject_obj) {
var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
subject_obj.unread = num_unread;
subject_obj.has_unread = num_unread !== 0;
subject_obj.is_zero = num_unread === 0;
if (subject === subject_obj.canon_subject) {
active_orig_subject = subject_obj.subject;
@ -161,6 +162,7 @@ function rebuild_recent_subjects(stream, subject) {
stream_li.append(templates.render('sidebar_subject_list',
{subjects: subjects,
stream: stream}));
if (active_orig_subject !== undefined) {
get_subject_filter_li(stream, active_orig_subject).addClass('active-subject-filter');
}

View File

@ -1600,3 +1600,7 @@ li.expanded_subject {
#pin_info_question:hover {
cursor: pointer;
}
.zero_count {
display: none;
}

View File

@ -3,9 +3,9 @@
<li class='expanded_subject' data-name='{{subject}}'>
<a href='#narrow/stream/{{../stream}}/subject/{{subject}}'>
{{subject}}
{{#if has_unread}}
<span class="subject_count">(<span class="value">{{unread}}</span>)</span>
{{/if}}
<span class="subject_count {{#if is_zero}}zero_count{{/if}}">
(<span class="value">{{unread}}</span>)
</span>
</a>
</li>
{{/each}}