mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 20:02:15 +00:00
Handle having no selected message more gracefully
(imported from commit ba00c012061b35dfe490bf1312b3fa78a4f6582f)
This commit is contained in:
@@ -48,8 +48,10 @@ function do_narrow(description, filter_function) {
|
|||||||
// is temporarily selected
|
// is temporarily selected
|
||||||
select_message_by_id(selected_message_id, {then_scroll: false});
|
select_message_by_id(selected_message_id, {then_scroll: false});
|
||||||
selected_message_class = "narrowed_selected_message";
|
selected_message_class = "narrowed_selected_message";
|
||||||
select_message_by_id(target_id, {then_scroll: true});
|
if (select_message_by_id(target_id, {then_scroll: true})) {
|
||||||
scroll_to_selected();
|
// Can only scroll if the message exists
|
||||||
|
scroll_to_selected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the message we're about to select, within the narrowed view.
|
// This is the message we're about to select, within the narrowed view.
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ function recenter_view(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scroll_to_selected() {
|
function scroll_to_selected() {
|
||||||
recenter_view(selected_message);
|
if (selected_message && (selected_message.length !== 0))
|
||||||
|
recenter_view(selected_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_huddle_recipient(message) {
|
function get_huddle_recipient(message) {
|
||||||
@@ -749,6 +750,8 @@ function at_bottom_of_viewport() {
|
|||||||
function keep_pointer_in_view() {
|
function keep_pointer_in_view() {
|
||||||
var candidate;
|
var candidate;
|
||||||
var next_message = rows.get(selected_message_id);
|
var next_message = rows.get(selected_message_id);
|
||||||
|
if (next_message.length === 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (above_view_threshold(next_message) && (!at_top_of_viewport())) {
|
if (above_view_threshold(next_message) && (!at_top_of_viewport())) {
|
||||||
while (above_view_threshold(next_message)) {
|
while (above_view_threshold(next_message)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user