diff --git a/static/js/activity.js b/static/js/activity.js index 5f5b348d52..6d56e4a8a8 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -157,9 +157,17 @@ function update_users() { var users = sort_users(Object.keys(presence_info), presence_info); + function get_num_unread(email) { + if (suppress_unread_counts) { + return 0; + } + return unread.num_unread_for_person(email); + } + var my_info = { name: page_params.fullname, email: page_params.email, + num_unread: get_num_unread(page_params.email), type: (activity.has_focus) ? activity.ACTIVE : activity.IDLE, type_desc: presence_descriptions.active, my_fullname: true @@ -170,6 +178,7 @@ function update_users() { return { name: people_dict.get(email).full_name, email: email, + num_unread: get_num_unread(email), type: presence, type_desc: presence_descriptions[presence] }; @@ -183,19 +192,6 @@ function update_users() { $('#user_presences').html(templates.render('user_presence_rows', {users: user_info})); - // Update the counts in the presence list. - if (!suppress_unread_counts) { - // We do this after rendering the template, to avoid dealing with - // the suppress_unread_counts conditional in the template. - - var set_count = function (email) { - stream_list.set_presence_list_count(email, unread.num_unread_for_person(email)); - }; - - _.each(user_emails, set_count); - set_count(page_params.email); - } - // Update user fading, if necessary. compose_fade.update_faded_users(); } diff --git a/static/styles/zulip.css b/static/styles/zulip.css index 526e679ff7..be60a1de5b 100644 --- a/static/styles/zulip.css +++ b/static/styles/zulip.css @@ -518,6 +518,10 @@ ul.filters { width: 150px; } +.user_sidebar_entry.user-with-count .count { + display: inherit; +} + .group-pms-sidebar-entry.group-with-count .selectable_sidebar_block { width: 170px; } diff --git a/static/templates/user_presence_rows.handlebars b/static/templates/user_presence_rows.handlebars index 441f2f4222..e726966834 100644 --- a/static/templates/user_presence_rows.handlebars +++ b/static/templates/user_presence_rows.handlebars @@ -1,12 +1,12 @@ {{! User Presence rows }} {{#each users}} -
  • +
  • {{name}} - + {{#if num_unread}}{{num_unread}}{{/if}}
  • {{/each}} diff --git a/zerver/tests/frontend/node/templates.js b/zerver/tests/frontend/node/templates.js index dfb5dab1e3..12b8208d01 100644 --- a/zerver/tests/frontend/node/templates.js +++ b/zerver/tests/frontend/node/templates.js @@ -522,12 +522,14 @@ function render(template_name, args) { "my_fullname": true, "type_desc": "Active", "type": "active", + "num_unread": 0, "email": "lear@zulip.com", "name": "King Lear" }, { "type_desc": "Away", "type": "away", + "num_unread": 5, "email": "othello@zulip.com", "name": "Othello" }