Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message list: Change locally echoed message ids synchronously.

Ryan Rehman3b5ba6b2c169
diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js
index b12e501adf5..c628daca640 100644
--- a/frontend_tests/node_tests/message_list.js
+++ b/frontend_tests/node_tests/message_list.js
@@ -7,6 +7,7 @@ const noop = function () {};
set_global('Filter', noop);
global.stub_out_jquery();
set_global('document', null);
+set_global('current_msg_list', {});
zrequire('FetchStatus', 'js/fetch_status');
zrequire('muting');
diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js
index b08eed08aca..3fb86815777 100644
--- a/static/js/message_list_data.js
+++ b/static/js/message_list_data.js
@@ -521,9 +521,7 @@ MessageListData.prototype = {
this._selected_id = new_id;
}
- setTimeout(() => {
- this.reorder_messages(new_id, opts);
- }, 0);
+ this.reorder_messages(new_id, opts);
},
reorder_messages: function (new_id, opts) {
@@ -553,7 +551,12 @@ MessageListData.prototype = {
self._all_items.sort(message_sort_func);
}
- opts.re_render();
+ // The data updates above need to happen synchronously,
+ // but the rerendering can be deferred. It's unclear
+ // whether this deferral is necessary; it was present in
+ // the original 2013 local echo implementation but we
+ // don't have records for why we added it then.
+ setTimeout(opts.re_render, 0);
}
},