mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
message list: Update MessageListData API by extracting reorder_messages.
`change_message_id` in `message_list_data.js` is only called from one place, the `change_message_id` function in `message_list.js`.
This commit is contained in:
@@ -502,8 +502,6 @@ MessageListData.prototype = {
|
|||||||
|
|
||||||
change_message_id: function (old_id, new_id, opts) {
|
change_message_id: function (old_id, new_id, opts) {
|
||||||
// Update our local cache that uses the old id to the new id
|
// Update our local cache that uses the old id to the new id
|
||||||
function message_sort_func(a, b) {return a.id - b.id;}
|
|
||||||
|
|
||||||
if (this._hash.has(old_id)) {
|
if (this._hash.has(old_id)) {
|
||||||
const msg = this._hash.get(old_id);
|
const msg = this._hash.get(old_id);
|
||||||
this._hash.delete(old_id);
|
this._hash.delete(old_id);
|
||||||
@@ -523,9 +521,15 @@ MessageListData.prototype = {
|
|||||||
this._selected_id = new_id;
|
this._selected_id = new_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.reorder_messages(new_id, opts);
|
||||||
|
}, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
reorder_messages: function (new_id, opts) {
|
||||||
|
function message_sort_func(a, b) {return a.id - b.id;}
|
||||||
// If this message is now out of order, re-order and re-render
|
// If this message is now out of order, re-order and re-render
|
||||||
const self = this;
|
const self = this;
|
||||||
setTimeout(() => {
|
|
||||||
const current_message = self._hash.get(new_id);
|
const current_message = self._hash.get(new_id);
|
||||||
const index = self._items.indexOf(current_message);
|
const index = self._items.indexOf(current_message);
|
||||||
|
|
||||||
@@ -551,7 +555,6 @@ MessageListData.prototype = {
|
|||||||
|
|
||||||
opts.re_render();
|
opts.re_render();
|
||||||
}
|
}
|
||||||
}, 0);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get_last_message_sent_by_me: function () {
|
get_last_message_sent_by_me: function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user