message_list: Avoid losing place when sending messages.

It can be pretty annoying to lose your place when replying to an old
message, even though every other chat application does this. And it
doesn't really buy us much; the user can always scroll down if they
want to, we have a helpful notification about where their message is
(which could be improved), and then we don't need to add some sort of
new complicated logic to avoid marking messages as read unexpectedly,
which the existing logic for this block badly needed.

(It had existing logic of that form dating from the pre-unread counts
pointer era).

Fixes #11462.
This commit is contained in:
Tim Abbott 2021-09-28 11:26:58 -07:00 committed by Tim Abbott
parent 53d9b5b307
commit 5191c41799
1 changed files with 0 additions and 26 deletions

View File

@ -840,32 +840,6 @@ export class MessageListView {
}
if (list === message_lists.current && messages_are_new) {
// First, in single-recipient narrows, potentially
// auto-scroll to the latest message if it was sent by us.
if (narrow_state.narrowed_by_reply()) {
const selected_id = list.selected_id();
let i;
// Iterate backwards to find the last message
// sent_by_me, stopping at the pointer position.
// There's a reasonable argument that this search
// should be limited in how far offscreen it's willing
// to go.
for (i = messages.length - 1; i >= 0; i -= 1) {
const id = messages[i].id;
if (id <= selected_id) {
break;
}
if (messages[i].sent_by_me && list.get(id) !== undefined) {
// If this is a reply we just sent, advance the pointer to it.
list.select_id(messages[i].id, {then_scroll: true});
return {
need_user_to_scroll: false,
};
}
}
}
if (started_scrolled_up) {
return {
need_user_to_scroll: true,