mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user