mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	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:
		@@ -9,6 +9,7 @@ global.stub_out_jquery();
 | 
			
		||||
zrequire('message_store');
 | 
			
		||||
zrequire('server_events_dispatch');
 | 
			
		||||
zrequire('server_events');
 | 
			
		||||
zrequire('sent_messages');
 | 
			
		||||
 | 
			
		||||
set_global('blueslip', global.make_zblueslip());
 | 
			
		||||
set_global('channel', {});
 | 
			
		||||
 
 | 
			
		||||
@@ -85,6 +85,9 @@ exports.insert_new_messages = function insert_new_messages(messages, sent_by_thi
 | 
			
		||||
 | 
			
		||||
    if (sent_by_this_client) {
 | 
			
		||||
        var need_user_to_scroll = render_info && render_info.need_user_to_scroll;
 | 
			
		||||
        // sent_by_this_client will be true if ANY of the messages
 | 
			
		||||
        // were sent by this client; notifications.notify_local_mixes
 | 
			
		||||
        // will filter out any not sent by us.
 | 
			
		||||
        notifications.notify_local_mixes(messages, need_user_to_scroll);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -598,11 +598,18 @@ exports.notify_local_mixes = function (messages, need_user_to_scroll) {
 | 
			
		||||
        checkable locally, so we may want to execute this code
 | 
			
		||||
        earlier in the codepath at some point and possibly punt
 | 
			
		||||
        on local rendering.
 | 
			
		||||
 | 
			
		||||
        Possible cleanup: Arguably, we should call this function
 | 
			
		||||
        unconditionally and just check if message.local_id is in
 | 
			
		||||
        sent_messages.messages here.
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    _.each(messages, function (message) {
 | 
			
		||||
        if (!people.is_my_user_id(message.sender_id)) {
 | 
			
		||||
            blueslip.warn('We did not expect messages sent by others to get here');
 | 
			
		||||
            // This can happen if the client is offline for a while
 | 
			
		||||
            // around the time this client sends a message; see the
 | 
			
		||||
            // caller of message_events.insert_new_messages.
 | 
			
		||||
            blueslip.info('Slightly unexpected: A message not sent by us batches with those that were.');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user