message_list: Fix messages marked as read during rendering.

I found a highly reproducible bug using the "Mark as unread" feature,
which triggers a rerender via message_list.rerender_view().

The reproducer was as follows:
* Navigate to a narrow by going to All messages and using the `S` hotkey.
* Mark as unread to mark several messages as unread in that view.
* Notice that the message that had been selected in home_message_list
  is immediately marked as read again.

What was happening is that the reselect_selected_id call for
message_lists.home (All messages) was incorrectly re-marking the
currently selected message as read, even though (1) that view was not
visible and (2) this was an internal rendering change that could not
be the first time the message was selected.

Because only the current message_list has marking messages as read
blocked, it's still able to mark the currently selected message as
read.

All the callers of reselect_selected_id are internal rendering code
paths that are not intended to be user-visible; as a result, they
should not change the unread state either.

The bug fixed here is a potential root cause of #16986, but I haven't
had a chacne to confirm it.
This commit is contained in:
Tim Abbott 2022-09-22 17:13:03 -07:00
parent 1b18f1fb5d
commit e7b97e25c9
1 changed files with 1 additions and 1 deletions

View File

@ -326,7 +326,7 @@ export class MessageList {
const selected_id = this.data.selected_id();
if (selected_id !== -1) {
this.select_id(this.data.selected_id(), {from_rendering: true});
this.select_id(this.data.selected_id(), {from_rendering: true, mark_read: false});
}
}