From 31e98b8b65cb83e91cf0aaf20195c44e05264a79 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 8 Feb 2019 14:49:48 -0800 Subject: [PATCH] message_list: Remove extra calls to update_timestr. We only generate message_containers in one place, and that code path already calls update_timestr. And update_timestr's effect only depends on the message. Thus, this code was useless. --- static/js/message_list_view.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 38b538bfad..547039d706 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -107,11 +107,9 @@ function clear_group_date_divider(group) { group.group_date_divider_html = undefined; } -function update_timestr(message_container) { - if (message_container.timestr === undefined) { - var time = new XDate(message_container.msg.timestamp * 1000); - message_container.timestr = timerender.stringify_time(time); - } +function set_timestr(message_container) { + var time = new XDate(message_container.msg.timestamp * 1000); + message_container.timestr = timerender.stringify_time(time); } function set_topic_edit_properties(group, message) { @@ -275,7 +273,7 @@ MessageListView.prototype = { } update_group_date_divider(current_group, message_container, prev); - update_timestr(message_container); + set_timestr(message_container); message_container.include_sender = true; if (!message_container.include_recipient && @@ -402,7 +400,6 @@ MessageListView.prototype = { first_group.message_containers[0])) { // The groups did not merge, so we need up update the date row for the old group update_group_date_divider(second_group, curr_msg_container, prev_msg_container); - update_timestr(curr_msg_container); // We could add an action to update the date row, but for now rerender the group. message_actions.rerender_groups.push(second_group); } @@ -421,7 +418,6 @@ MessageListView.prototype = { // If we just sent the first message on a new day // in a narrow, make sure we render a date separator. update_group_date_divider(second_group, curr_msg_container, prev_msg_container); - update_timestr(curr_msg_container); } } message_actions.append_groups = new_message_groups;