From 860406d1ad89db3b4b31c25589db05f88f12d3c7 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Wed, 13 Mar 2019 15:49:45 +0530 Subject: [PATCH] message_list_view: Extract `_get_msg_timestring` method. This method gets the timestring for the message container when the message was last edited. --- static/js/message_list_view.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 2853b3ffe0..7b21816cc6 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -191,14 +191,19 @@ MessageListView.prototype = { // trigger a re-render _RENDER_THRESHOLD: 50, - _add_msg_timestring: function (message_container) { + _get_msg_timestring: function (message_container) { if (message_container.msg.last_edit_timestamp !== undefined) { - // Add or update the last_edit_timestr var last_edit_time = new XDate(message_container.msg.last_edit_timestamp * 1000); var today = new XDate(); - message_container.last_edit_timestr = - timerender.render_date(last_edit_time, undefined, today)[0].textContent - + " at " + timerender.stringify_time(last_edit_time); + return timerender.render_date(last_edit_time, undefined, today)[0].textContent + + " at " + timerender.stringify_time(last_edit_time); + } + }, + + _add_msg_timestring: function (message_container) { + var last_edit_timestr = this._get_msg_timestring(message_container); + if (last_edit_timestr !== undefined) { + message_container.last_edit_timestr = last_edit_timestr; } },