mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
Move user list unread-count logic to templates.
When we rebuild the user list from scratch, set the unread counts in the templates to avoid multiple DOM updates. (imported from commit 2d0c9b0fb99b382332e464ba7c3caad95e05363e)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{{! User Presence rows }}
|
||||
{{#each users}}
|
||||
<li data-email="{{email}}" class="user_sidebar_entry narrow-filter user_{{type}}">
|
||||
<li data-email="{{email}}" class="user_sidebar_entry {{#if num_unread}}user-with-count {{/if}}narrow-filter user_{{type}}">
|
||||
<span class="selectable_sidebar_block">
|
||||
<span class="user-status-indicator"></span>
|
||||
<a href="#" data-email="{{email}}" data-name="{{name}}" title="{{name}} {{type_desc}}"
|
||||
class="{{#if my_fullname}} my_fullname{{/if}}">{{name}}</a>
|
||||
</span>
|
||||
<span class="count"><span class="value"></span></span>
|
||||
<span class="count"><span class="value">{{#if num_unread}}{{num_unread}}{{/if}}</span></span>
|
||||
<span class="arrow"><i class="icon-vector-chevron-down"></i></span>
|
||||
</li>
|
||||
{{/each}}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user