mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	message_list: Move set_message_offset into message_list_view.
The refactor in 12509515ae had a subtle
bug, which is that we switched from accessing the message list "this"
(aka the message list being rerendered) to current_msg_list.  This
meant that when the narrowed_msg_list was in view and code needed to
modify home_msg_list, we accessed the wrong `selected_row` to preserve
the scroll position of (namely, the one in current_msg_list, not the
one in home_msg_list).
Fix this, by moving the function to be a property of the
message_list_view object, which makes more sense structurally, anyway.
We may, in the future, want to do a similar migration for more of
message_viewport.js.
Fixes #8854.
			
			
This commit is contained in:
		@@ -485,7 +485,7 @@ MessageListView.prototype = {
 | 
			
		||||
 | 
			
		||||
        function restore_scroll_position() {
 | 
			
		||||
            if (list === current_msg_list && orig_scrolltop_offset !== undefined) {
 | 
			
		||||
                message_viewport.set_message_offset(orig_scrolltop_offset);
 | 
			
		||||
                list.view.set_message_offset(orig_scrolltop_offset);
 | 
			
		||||
                list.reselect_selected_id();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -815,6 +815,11 @@ MessageListView.prototype = {
 | 
			
		||||
        return this.rerender_with_target_scrolltop(selected_row, old_offset);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    set_message_offset: function (offset) {
 | 
			
		||||
        var msg = this.selected_row();
 | 
			
		||||
        message_viewport.scrollTop(message_viewport.scrollTop() + msg.offset().top - offset);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    rerender_with_target_scrolltop: function (selected_row, target_offset) {
 | 
			
		||||
        // target_offset is the target number of pixels between the top of the
 | 
			
		||||
        // viewable window and the selected message
 | 
			
		||||
@@ -831,7 +836,7 @@ MessageListView.prototype = {
 | 
			
		||||
                this.list.select_id(this.list.selected_id(), {use_closest: true});
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            message_viewport.set_message_offset(target_offset);
 | 
			
		||||
            this.set_message_offset(target_offset);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user