Show unread subjects in stream sidebar.

Trac #1403.

This shows the 5 most recent subjects, as well as any others with unread messages. This
requires tracking all subjects and filtering at display time, rather than filtering when
building the subject list.

(imported from commit 8bda7d50e6785a6e70abea4b3af4d03a16d076d3)
This commit is contained in:
Kevin Mehall 2013-06-27 10:26:33 -04:00
parent 1e246ba32d
commit 371b3827d2
2 changed files with 6 additions and 6 deletions

View File

@ -155,10 +155,11 @@ function rebuild_recent_subjects(stream, subject) {
// TODO: Call rebuild_recent_subjects less, not on every new
// message.
$('.expanded_subjects').remove();
var max_subjects = 5;
var stream_li = get_filter_li('stream', stream);
var subjects = recent_subjects[stream] || [];
var active_orig_subject = subject;
$.each(subjects, function (idx, subject_obj) {
var display_subjects = $.grep(subjects, function (subject_obj, idx) {
var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
subject_obj.unread = num_unread;
subject_obj.is_zero = num_unread === 0;
@ -167,11 +168,13 @@ function rebuild_recent_subjects(stream, subject) {
active_orig_subject = subject_obj.subject;
}
subject_obj.url = narrow.by_stream_subject_uri(stream, subject_obj.subject);
// Show the most recent subjects, as well as any with unread messages
return idx < max_subjects || subject_obj.unread > 0;
});
stream_li.append(templates.render('sidebar_subject_list',
{subjects: subjects,
{subjects: display_subjects,
stream: stream}));
if (active_orig_subject !== undefined) {

View File

@ -495,7 +495,6 @@ function case_insensitive_find(term, array) {
function process_message_for_recent_subjects(message, remove_message) {
var current_timestamp = 0;
var max_subjects = 5;
var count = 0;
var canon_stream = subs.canonicalized_name(message.stream);
var canon_subject = subs.canonicalized_name(message.subject);
@ -534,8 +533,6 @@ function process_message_for_recent_subjects(message, remove_message) {
return b.timestamp - a.timestamp;
});
recents = recents.slice(0, max_subjects);
recent_subjects[canon_stream] = recents;
}