mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
message_fetch: Fix load_messages called unexpectedly.
Since we set a new timeout on every connection error, we can unconditionally clear the timeout when load_messages is called. This fixes the error when `load_messages` is called irrespective of `delay_secs` timer.
This commit is contained in:
@@ -394,25 +394,22 @@ export function load_messages(opts: MessageFetchOptions, attempt = 1): void {
|
||||
});
|
||||
}
|
||||
|
||||
if (load_messages_timeout !== undefined) {
|
||||
clearTimeout(load_messages_timeout);
|
||||
}
|
||||
|
||||
void channel.get({
|
||||
url: "/json/messages",
|
||||
data,
|
||||
success(raw_data) {
|
||||
if (load_messages_timeout !== undefined) {
|
||||
clearTimeout(load_messages_timeout);
|
||||
}
|
||||
popup_banners.close_connection_error_popup_banner("message_fetch");
|
||||
const data = response_schema.parse(raw_data);
|
||||
get_messages_success(data, opts);
|
||||
},
|
||||
error(xhr) {
|
||||
if (xhr.status === 400) {
|
||||
// We successfully reached the server, so hide the
|
||||
// connection error notice, even if the request failed
|
||||
// for other reasons.
|
||||
if (load_messages_timeout !== undefined) {
|
||||
clearTimeout(load_messages_timeout);
|
||||
}
|
||||
// Even though the request failed, we did reach the
|
||||
// server, and can hide the connection error notice.
|
||||
popup_banners.close_connection_error_popup_banner("message_fetch");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user