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,
|
||||
dataType: 'json',
|
||||
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) {
|
||||
// The server occationally returns no data during a
|
||||
// restart. Ignore those responses and try again
|
||||
|
@ -706,6 +711,11 @@ function load_old_messages(opts) {
|
|||
process_result(data.messages);
|
||||
},
|
||||
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) {
|
||||
// Bad request: We probably specified a narrow operator
|
||||
// for a nonexistent stream or something. We shouldn't
|
||||
|
@ -792,6 +802,7 @@ function restart_get_updates(options) {
|
|||
function reset_load_more_status() {
|
||||
load_more_enabled = true;
|
||||
have_scrolled_away_from_top = true;
|
||||
ui.hide_loading_more_messages_indicator();
|
||||
}
|
||||
|
||||
function load_more_messages(msg_list) {
|
||||
|
|
Loading…
Reference in New Issue