Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
message view: Don't mark selected message as read when narrowing.
On activating a narrow we always mark the first message it selects as read, which is usually the first unread message. This behaviour is unwanted. The flow is as follows: * On activating the narrow we call the `MessageList.select_id` method along with a `force_rerender` param. Here event = { id: X, previously_selected_id: -1, ... } where X = the first unread message id to be selected. * Due to this `force_rerender` field, we first call the `rerender` method and then trigger our custom event handler (`message_selected.zulip`) which is responsible for marking message as read. * However, due to this call path: `this.select_id` > `this.rerender` > `this.rerender_view` > `this.redo_selection` > `this.select_id`, the `message_selected.zulip` event gets triggered with event as = { id: X, previously_selected_id: X, ... } * Thus the second selection event gets triggered before the first one having the current and previous id equal to "X". This above `id = previously_selected_id` consition only occurs for narrow activation (due to the `force_rerender` flag) or when a message is selected again by clicking on it (message is already read in this case). For the All Messages view we have similar logic where, we pass `mark_read` as false (which was previously unused) which skips the "message_selected.zulip" event in `message_scroll.js`. Work towards #10886.
- Loading branch information