notification: Show wrong narrow notification for non locally echoed message.

Show "sent to different narrow" notification and other such notification by
notifications.notify_local_mixes for non locally echoed message sent by
current client.

With significant new comments added by tabbott.

Fixes: #11488.
This commit is contained in:
Mohit Gupta
2019-02-12 07:55:26 +05:30
committed by Tim Abbott
parent e5f28ca78e
commit bf14f4cd7b
4 changed files with 29 additions and 2 deletions

View File

@@ -104,7 +104,23 @@ function get_events_success(events) {
try {
messages = echo.process_from_server(messages);
_.each(messages, message_store.set_message_booleans);
message_events.insert_new_messages(messages);
var sent_by_this_client = false;
_.each(messages, function (msg) {
var msg_state = sent_messages.messages[msg.local_id];
if (msg_state) {
// Almost every time, this message will be the
// only one in messages, because multiple messages
// being returned by get_events usually only
// happens when a client is offline, but we know
// this client just sent a message in this batch
// of events. But in any case,
// insert_new_messages handles multiple messages,
// only one of which was sent by this client,
// correctly.
sent_by_this_client = true;
}
});
message_events.insert_new_messages(messages, sent_by_this_client);
} catch (ex2) {
blueslip.error('Failed to insert new messages\n' +
blueslip.exception_msg(ex2),