mirror of https://github.com/zulip/zulip.git
message_edit: Fix edit last msg hotkey unintentionally marks msgs read.
Fixes #17737 If you write a message in a narrowed view, then go back to an unnarrowed view, there may now be many unread messages between your new current position and the message you just wrote. If you then accidentally press `←`, all of those messages will be marked read unexpectedly, causing you to lose your place while catching up. So, we disable the hotkey in this scenario to fix this bug.
This commit is contained in:
parent
dd58698c02
commit
98265fd149
|
@ -1272,6 +1272,18 @@ export function edit_last_sent_message(): void {
|
|||
return;
|
||||
}
|
||||
|
||||
const current_selected_msg = message_store.get(message_lists.current.selected_id());
|
||||
if (current_selected_msg && current_selected_msg.id < last_sent_msg.id) {
|
||||
// If there are any unread messages between the selected message and the
|
||||
// message we want to edit, we don't edit the last sent message to avoid
|
||||
// marking messages as read unintentionally.
|
||||
for (const msg of message_lists.current.all_messages()) {
|
||||
if (current_selected_msg.id < msg.id && msg.id < last_sent_msg.id && msg.unread) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message_lists.current.select_id(last_sent_msg.id, {then_scroll: true});
|
||||
|
||||
const $msg_row = message_lists.current.get_row(last_sent_msg.id);
|
||||
|
|
Loading…
Reference in New Issue