mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
admin users: Use plain HTML and static dates.
We want to avoid creating jQuery objects that just get turned right back into strings by the list widget, so we now have our template just include `last_active_date` instead of kludging it in after the fact, and we return the template string in `modifier` rather than wrapping it. To deal with plain HTML we switch to using `render_now`. Calling `render_now` leads to a more simple codepath than `render_date`, beyond just dealing with text. The `render_date` function has special-case logic that only applies to our time dividers in our message view, which is why we were passing the strange `undefined` parameter to it before this fix. The `render_date` function was also putting the dates into `update_list` for once-a-day updates, which is overkill for an admin screen. We don't use this logic for drafts or attachments either. I'm not sure how well tested that logic is, and it's prone to slow leaks. This commit sets us up to simplify the list widget not to have bit-rot-prone code related to jQuery objects.
This commit is contained in:
@@ -197,28 +197,26 @@ function populate_users(realm_people_data) {
|
||||
},
|
||||
});
|
||||
|
||||
function get_rendered_last_activity(user) {
|
||||
function get_last_active(user) {
|
||||
const last_active_date = presence.last_active_date(user.user_id);
|
||||
|
||||
if (!last_active_date) {
|
||||
return $("<span></span>").text(i18n.t("Unknown"));
|
||||
return i18n.t("Unknown");
|
||||
}
|
||||
const today = new XDate();
|
||||
return timerender.render_date(last_active_date, undefined, today);
|
||||
return timerender.render_now(last_active_date).time_str;
|
||||
}
|
||||
|
||||
const $users_table = $("#admin_users_table");
|
||||
list_render.create($users_table, active_users, {
|
||||
name: "users_table_list",
|
||||
modifier: function (item) {
|
||||
const $row = $(render_admin_user_list({
|
||||
return render_admin_user_list({
|
||||
can_modify: page_params.is_admin,
|
||||
is_current_user: people.is_my_user_id(item.user_id),
|
||||
display_email: settings_data.email_for_user_settings(item),
|
||||
user: item,
|
||||
}));
|
||||
$row.find(".last_active").append(get_rendered_last_activity(item));
|
||||
return $row;
|
||||
last_active_date: get_last_active(item),
|
||||
});
|
||||
},
|
||||
filter: {
|
||||
element: $users_table.closest(".settings-section").find(".search"),
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
</td>
|
||||
{{else if is_active}}
|
||||
<td class="last_active">
|
||||
{{ ../last_active_date }}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{#if ../can_modify}}
|
||||
|
||||
Reference in New Issue
Block a user