mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
scrolling: Fix out-of-order bug in the message list.
The issue has a lot of extra details, but in short, if several messages were sent at very close to the same time, it's possible that the event queues will receive the "new message" events out-of-order. This, in turn, could cause `get_events` to return an incorrectly sorted block of messages. These would then be passed into `message_list.add_messages`, which doesn't handle that sort of unsorted situation correctly (in short, the `self.first.id()` comparison checks are not accurate for that situation, since we don't update the boundaries after the first messages is processed). The end result of this bug was that it was possible for the message list to be out-of-order, which in turn would cause exceptions when scrolling with the mouse. Fixes #6948.
This commit is contained in:
@@ -89,6 +89,10 @@ function get_events_success(events) {
|
||||
});
|
||||
|
||||
if (messages.length !== 0) {
|
||||
// Sort by ID, so that if we get multiple messages back from
|
||||
// the server out-of-order, we'll still end up with our
|
||||
// message lists in order.
|
||||
messages = _.sortBy(messages, 'id');
|
||||
try {
|
||||
messages = echo.process_from_server(messages);
|
||||
message_events.insert_new_messages(messages);
|
||||
|
||||
Reference in New Issue
Block a user