mirror of https://github.com/zulip/zulip.git
Don't do processing for a get_old_messages if the message list it was for goes away
This was biting us before when the user would leave a narrow before a get_old_messages call associated with it finished. Specifically, search.maybe_highlight_message() would assume a message was in the DOM when it wasn't any more. We also have to hide the 'loading more messages' indicator when reseting the 'load more' status because otherwise it wouldn't get hidden like normal in the load_old_messages() continuation, causing a load_more_messages() not to fire when re-entering a narrow. (imported from commit 4a136dd01305b039c0970f897b07e603b87d5d8e)
This commit is contained in:
parent
7e456ddba7
commit
53a68144e0
|
@ -694,6 +694,11 @@ function load_old_messages(opts) {
|
||||||
data: data,
|
data: data,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
if (opts.for_narrow && opts.msg_list !== current_msg_list) {
|
||||||
|
// We unnarrowed before receiving new messages so
|
||||||
|
// don't bother processing the newly arrived messages.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (! data) {
|
if (! data) {
|
||||||
// The server occationally returns no data during a
|
// The server occationally returns no data during a
|
||||||
// restart. Ignore those responses and try again
|
// restart. Ignore those responses and try again
|
||||||
|
@ -706,6 +711,11 @@ function load_old_messages(opts) {
|
||||||
process_result(data.messages);
|
process_result(data.messages);
|
||||||
},
|
},
|
||||||
error: function (xhr, error_type, exn) {
|
error: function (xhr, error_type, exn) {
|
||||||
|
if (opts.for_narrow && opts.msg_list !== current_msg_list) {
|
||||||
|
// We unnarrowed before getting an error so don't
|
||||||
|
// bother trying again or doing further processing.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (xhr.status === 400) {
|
if (xhr.status === 400) {
|
||||||
// Bad request: We probably specified a narrow operator
|
// Bad request: We probably specified a narrow operator
|
||||||
// for a nonexistent stream or something. We shouldn't
|
// for a nonexistent stream or something. We shouldn't
|
||||||
|
@ -792,6 +802,7 @@ function restart_get_updates(options) {
|
||||||
function reset_load_more_status() {
|
function reset_load_more_status() {
|
||||||
load_more_enabled = true;
|
load_more_enabled = true;
|
||||||
have_scrolled_away_from_top = true;
|
have_scrolled_away_from_top = true;
|
||||||
|
ui.hide_loading_more_messages_indicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_more_messages(msg_list) {
|
function load_more_messages(msg_list) {
|
||||||
|
|
Loading…
Reference in New Issue