mirror of https://github.com/zulip/zulip.git
message_list: Move and deduplicate reselect_selected_id functions.
redo_selection and reselect_selected_id did the same thing: Reselect the currently selected message as a result of internal rendering. I combine the useful features of both -- not crashing if no message is selected (id -1) and passing the `from_rendering` option, to avoid potentially triggering an additional rerender.
This commit is contained in:
parent
eba390c6b2
commit
1b18f1fb5d
|
@ -203,10 +203,6 @@ export class MessageList {
|
|||
$(document).trigger(new $.Event("message_selected.zulip", opts));
|
||||
}
|
||||
|
||||
reselect_selected_id() {
|
||||
this.select_id(this.data.selected_id(), {from_rendering: true});
|
||||
}
|
||||
|
||||
selected_message() {
|
||||
return this.get(this.data.selected_id());
|
||||
}
|
||||
|
@ -326,9 +322,17 @@ export class MessageList {
|
|||
$row.removeClass("unread");
|
||||
}
|
||||
|
||||
reselect_selected_id() {
|
||||
const selected_id = this.data.selected_id();
|
||||
|
||||
if (selected_id !== -1) {
|
||||
this.select_id(this.data.selected_id(), {from_rendering: true});
|
||||
}
|
||||
}
|
||||
|
||||
rerender_view() {
|
||||
this.view.rerender_preserving_scrolltop();
|
||||
this.redo_selection();
|
||||
this.reselect_selected_id();
|
||||
}
|
||||
|
||||
rerender() {
|
||||
|
@ -349,14 +353,6 @@ export class MessageList {
|
|||
this.rerender_view();
|
||||
}
|
||||
|
||||
redo_selection() {
|
||||
const selected_id = this.data.selected_id();
|
||||
|
||||
if (selected_id !== -1) {
|
||||
this.select_id(selected_id);
|
||||
}
|
||||
}
|
||||
|
||||
update_muting_and_rerender() {
|
||||
this.data.update_items_for_muting();
|
||||
// We need to rerender whether or not the narrow hides muted
|
||||
|
|
Loading…
Reference in New Issue